Commit 09fe67b5 authored by Guillaume Seguin's avatar Guillaume Seguin

Switch to orthographic projection

parent b88342ef
...@@ -34,6 +34,8 @@ from .libtatlin import actors ...@@ -34,6 +34,8 @@ from .libtatlin import actors
class wxGLPanel(wx.Panel): class wxGLPanel(wx.Panel):
'''A simple class for using OpenGL with wxPython.''' '''A simple class for using OpenGL with wxPython.'''
orthographic = True
def __init__(self, parent, id, pos = wx.DefaultPosition, def __init__(self, parent, id, pos = wx.DefaultPosition,
size = wx.DefaultSize, style = 0): size = wx.DefaultSize, style = 0):
# Forcing a no full repaint to stop flickering # Forcing a no full repaint to stop flickering
...@@ -119,9 +121,15 @@ class wxGLPanel(wx.Panel): ...@@ -119,9 +121,15 @@ class wxGLPanel(wx.Panel):
glViewport(0, 0, width, height) glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION) glMatrixMode(GL_PROJECTION)
glLoadIdentity() glLoadIdentity()
gluPerspective(60., width / float(height), 10.0, 3 * self.dist) if self.orthographic:
glOrtho(-width / 2, width / 2, -height / 2, height / 2, 0.1, 3 * self.dist)
else:
gluPerspective(60., float(width) / height, 10.0, 3 * self.dist)
glMatrixMode(GL_MODELVIEW) glMatrixMode(GL_MODELVIEW)
glLoadIdentity() glLoadIdentity()
if self.orthographic:
ratio = 0.9 * float(min(self.width, self.height)) / self.dist
glScalef(ratio, ratio, 1)
# Wrap text to the width of the window # Wrap text to the width of the window
if self.GLinitialized: if self.GLinitialized:
...@@ -386,6 +394,9 @@ class GcodeViewPanel(wxGLPanel): ...@@ -386,6 +394,9 @@ class GcodeViewPanel(wxGLPanel):
def mouse_to_3d(self, x, y): def mouse_to_3d(self, x, y):
x = float(x) x = float(x)
y = self.height - float(y) y = self.height - float(y)
# The following could work if we were not initially scaling to zoom on the bed
#if self.orthographic:
# return (x - self.width / 2, y - self.height / 2, 0)
pmat = (GLdouble * 16)() pmat = (GLdouble * 16)()
mvmat = (GLdouble * 16)() mvmat = (GLdouble * 16)()
viewport = (GLint * 4)() viewport = (GLint * 4)()
......
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