From 655ab135e5bd34918cae12b3f5e4600df55d728f Mon Sep 17 00:00:00 2001 From: kliment Date: Fri, 15 Jul 2011 09:15:12 +0200 Subject: [PATCH] Fix permissions, allow commands when printer disconnected --- .gitignore | 2 +- gviz.py | 21 +++++++++++++++++++++ plater.py | 40 +++++++++++++++++++++++----------------- printcore.py | 0 pronsole.py | 0 pronterface.py | 4 ++-- 6 files changed, 47 insertions(+), 20 deletions(-) mode change 100644 => 100755 gviz.py mode change 100644 => 100755 plater.py mode change 100644 => 100755 printcore.py mode change 100644 => 100755 pronsole.py mode change 100644 => 100755 pronterface.py diff --git a/.gitignore b/.gitignore index 171e83c..7f75692 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ *.pyc -.pronsolerc \ No newline at end of file +.pronsolerc diff --git a/gviz.py b/gviz.py old mode 100644 new mode 100755 index 5eb43a4..b2e84e5 --- a/gviz.py +++ b/gviz.py @@ -8,11 +8,32 @@ class window(wx.Frame): for i in f: self.p.addgcode(i) #print time.time()-s + self.initpos=[0,0] self.p.Bind(wx.EVT_KEY_DOWN,self.key) self.Bind(wx.EVT_KEY_DOWN,self.key) self.p.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): x=event.GetKeyCode() #print x diff --git a/plater.py b/plater.py old mode 100644 new mode 100755 index 975456f..eff2023 --- a/plater.py +++ b/plater.py @@ -53,10 +53,15 @@ class showstl(wx.Window): return path = os.path.split(name)[0] self.basedir=path + t=time.time() + #print name if name.lower().endswith(".stl"): 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.Refresh() + #print time.time()-t def move(self,event): if event.ButtonUp(wx.MOUSE_BTN_LEFT): @@ -65,7 +70,11 @@ class showstl(wx.Window): if i != -1: p=event.GetPositionTuple() #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.initpos=None elif event.ButtonDown(wx.MOUSE_BTN_RIGHT): @@ -84,7 +93,7 @@ class showstl(wx.Window): event.Skip() def cr(self): - time.sleep(0.1) + time.sleep(0.01) if(self.i!=self.previ): i=self.l.GetFirstSelected() if i != -1: @@ -98,7 +107,6 @@ class showstl(wx.Window): s=self.l.GetFirstSelected() if self.prevsel!=s: self.i=0 - print "reset" self.prevsel=s if z > 0: self.i-=1 @@ -114,28 +122,26 @@ class showstl(wx.Window): def paint(self,coord1="x",coord2="y",dc=None): 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: dc=wx.ClientDC(self) - #self.facet=[normal,[[0,0,0],[0,0,0],[0,0,0]]] - offset=200 - scale=2 + offset=[0,0] + scale=3 + 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 i in random.sample(m.facets,min(1000,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.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]]) - 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]]) + for i in m.facets:#random.sample(m.facets,min(100000,len(m.facets))): + 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]]) + #if(time.time()-t)>5: + # break del dc + print time.time()-t #s.export() 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) - self.s=showstl(self,(500,600),(100,100)) + self.s=showstl(self,(600,700),(0,0)) if __name__ == '__main__': app = wx.App(False) diff --git a/printcore.py b/printcore.py old mode 100644 new mode 100755 diff --git a/pronsole.py b/pronsole.py old mode 100644 new mode 100755 diff --git a/pronterface.py b/pronterface.py old mode 100644 new mode 100755 index 565ec7f..7b35ca2 --- a/pronterface.py +++ b/pronterface.py @@ -304,11 +304,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole): lbrs=wx.BoxSizer(wx.HORIZONTAL) 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.printerControls.append(self.commandbox) + #self.printerControls.append(self.commandbox) lbrs.Add(self.commandbox) self.sendbtn=wx.Button(self.panel,-1,"Send",pos=(700,420)) self.sendbtn.Bind(wx.EVT_BUTTON,self.sendline) - self.printerControls.append(self.sendbtn) + #self.printerControls.append(self.sendbtn) lbrs.Add(self.sendbtn) lrs.Add(lbrs)