Commit 344cee84 authored by Kliment Yanev's avatar Kliment Yanev

Make gviz scale

parent 3772428e
...@@ -61,7 +61,7 @@ class gviz(wx.Panel): ...@@ -61,7 +61,7 @@ class gviz(wx.Panel):
self.lastpos=[0,0,0,0,0,0,0] self.lastpos=[0,0,0,0,0,0,0]
self.hilightpos=self.lastpos[:] self.hilightpos=self.lastpos[:]
self.Bind(wx.EVT_PAINT,self.paint) self.Bind(wx.EVT_PAINT,self.paint)
self.Bind(wx.EVT_SIZE,lambda *e:(wx.CallAfter(self.repaint),wx.CallAfter(self.Refresh))) self.Bind(wx.EVT_SIZE,self.resize)
self.lines={} self.lines={}
self.pens={} self.pens={}
self.arcs={} self.arcs={}
...@@ -69,7 +69,8 @@ class gviz(wx.Panel): ...@@ -69,7 +69,8 @@ class gviz(wx.Panel):
self.layers=[] self.layers=[]
self.layerindex=0 self.layerindex=0
self.filament_width=extrusion_width # set it to 0 to disable scaling lines with zoom self.filament_width=extrusion_width # set it to 0 to disable scaling lines with zoom
self.scale=[min(float(size[0])/bedsize[0],float(size[1])/bedsize[1])]*2 self.basescale=[min(float(size[0])/bedsize[0],float(size[1])/bedsize[1])]*2
self.scale=self.basescale
penwidth = max(1.0,self.filament_width*((self.scale[0]+self.scale[1])/2.0)) penwidth = max(1.0,self.filament_width*((self.scale[0]+self.scale[1])/2.0))
self.translate=[0.0,0.0] self.translate=[0.0,0.0]
self.mainpen=wx.Pen(wx.Colour(0,0,0),penwidth) self.mainpen=wx.Pen(wx.Colour(0,0,0),penwidth)
...@@ -118,9 +119,16 @@ class gviz(wx.Panel): ...@@ -118,9 +119,16 @@ class gviz(wx.Panel):
except: except:
pass pass
def resize(self,event):
size=self.GetClientSize()
newsize=min(float(size[0])/self.size[0],float(size[1])/self.size[1])
self.size=self.GetClientSize()
wx.CallAfter(self.zoom,0,0,newsize)
def zoom(self,x,y,factor): def zoom(self,x,y,factor):
self.scale = [s * factor for s in self.scale] self.scale = [s * factor for s in self.scale]
self.translate = [ x - (x-self.translate[0]) * factor, self.translate = [ x - (x-self.translate[0]) * factor,
y - (y-self.translate[1]) * factor] y - (y-self.translate[1]) * factor]
penwidth = max(1.0,self.filament_width*((self.scale[0]+self.scale[1])/2.0)) penwidth = max(1.0,self.filament_width*((self.scale[0]+self.scale[1])/2.0))
...@@ -130,6 +138,7 @@ class gviz(wx.Panel): ...@@ -130,6 +138,7 @@ class gviz(wx.Panel):
self.repaint() self.repaint()
self.Refresh() self.Refresh()
def repaint(self): def repaint(self):
self.blitmap=wx.EmptyBitmap(self.GetClientSize()[0],self.GetClientSize()[1],-1) self.blitmap=wx.EmptyBitmap(self.GetClientSize()[0],self.GetClientSize()[1],-1)
dc=wx.MemoryDC() dc=wx.MemoryDC()
......
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