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

Cleanup translation handling in stlview

parent c312d850
...@@ -176,13 +176,12 @@ class StlViewPanel(wxGLPanel): ...@@ -176,13 +176,12 @@ class StlViewPanel(wxGLPanel):
self.initpos = event.GetPositionTuple() self.initpos = event.GetPositionTuple()
else: else:
if not event.ShiftDown(): if not event.ShiftDown():
currentpos = event.GetPositionTuple() p1 = self.initpos
delta = ( p2 = event.GetPositionTuple()
(currentpos[0] - self.initpos[0]), x1, y1, _ = self.mouse_to_3d(p1[0], p1[1])
-(currentpos[1] - self.initpos[1]) x2, y2, _ = self.mouse_to_3d(p2[0], p2[1])
) self.move_shape((x2 - x1, y2 - y1))
self.move_shape(delta) self.initpos = p2
self.initpos = None
return return
p1 = self.initpos p1 = self.initpos
p2 = event.GetPositionTuple() p2 = event.GetPositionTuple()
...@@ -208,14 +207,12 @@ class StlViewPanel(wxGLPanel): ...@@ -208,14 +207,12 @@ class StlViewPanel(wxGLPanel):
else: else:
p1 = self.initpos p1 = self.initpos
p2 = event.GetPositionTuple() p2 = event.GetPositionTuple()
sz = self.GetClientSize() if self.orthographic:
p1 = list(p1) x1, y1, _ = self.mouse_to_3d(p1[0], p1[1])
p2 = list(p2) x2, y2, _ = self.mouse_to_3d(p2[0], p2[1])
p1[1] *= -1 glTranslatef(x2 - x1, y2 - y1, 0)
p2[1] *= -1 else:
glTranslatef(p2[0] - p1[0], -(p2[1] - p1[1]), 0)
self.transv = map(lambda x, y, z, c: c - self.dist * (x - y) / z, list(p1) + [0], list(p2) + [0], list(sz) + [1], self.transv)
self.initpos = p2 self.initpos = p2
def rotate_shape(self, angle): def rotate_shape(self, angle):
...@@ -256,13 +253,6 @@ class StlViewPanel(wxGLPanel): ...@@ -256,13 +253,6 @@ class StlViewPanel(wxGLPanel):
else: else:
self.transv[2] -= angle self.transv[2] -= angle
glLoadIdentity()
glTranslatef(*self.transv)
if(self.rot):
glMultMatrixd(build_rotmatrix(self.basequat))
glGetDoublev(GL_MODELVIEW_MATRIX, self.mvmat)
self.rot = 1
def keypress(self, event): def keypress(self, event):
"""gets keypress events and moves/rotates acive shape""" """gets keypress events and moves/rotates acive shape"""
keycode = event.GetKeyCode() keycode = event.GetKeyCode()
......
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