Commit 1b4d8490 authored by Guillaume Seguin's avatar Guillaume Seguin

Update zooming in stlview

parent 3486a5f4
......@@ -178,3 +178,14 @@ class wxGLPanel(wx.Panel):
glGetDoublev(GL_MODELVIEW_MATRIX, mvmat)
gluUnProject(x, y, 1.0, mvmat, pmat, viewport, px, py, pz)
return (px.value, py.value, pz.value)
def zoom(self, factor, to = None):
glMatrixMode(GL_MODELVIEW)
if to:
delta_x = to[0]
delta_y = to[1]
glTranslatef(delta_x, delta_y, 0)
glScalef(factor, factor, 1)
if to:
glTranslatef(-delta_x, -delta_y, 0)
wx.CallAfter(self.Refresh)
......@@ -231,27 +231,21 @@ class StlViewPanel(wxGLPanel):
rotate object
with shift zoom viewport
"""
z = event.GetWheelRotation()
angle = 10
delta = event.GetWheelRotation()
if not event.ShiftDown():
i = self.parent.l.GetSelection()
if i < 0:
try:
self.parent.setlayerindex(z)
except:
pass
return
if z > 0:
angle = 10
if delta > 0:
self.rotate_shape(angle / 2)
else:
self.rotate_shape(-angle / 2)
return
if z > 0:
self.transv[2] += angle
else:
self.transv[2] -= angle
factor = 1.05
x, y = event.GetPositionTuple()
x, y, _ = self.mouse_to_3d(x, y)
if delta > 0:
self.zoom(factor, (x, y))
else:
self.zoom(1/factor, (x, y))
def keypress(self, event):
"""gets keypress events and moves/rotates acive shape"""
......
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