Added a proper toolbar to the 3D preview.

Fixed pypy run (wx error)
master
daid 2012-02-23 14:08:34 +01:00
parent 7183ac0d4a
commit bdb4b5b4e9
4 changed files with 35 additions and 16 deletions

View File

@ -102,7 +102,7 @@ class mainWindow(wx.Frame):
nb.AddPage(alterationPanel.alterationPanel(nb), "Start/End-GCode") nb.AddPage(alterationPanel.alterationPanel(nb), "Start/End-GCode")
#Preview window, load and slice buttons. #Preview window, load and slice buttons.
self.preview3d = preview3d.myGLCanvas(p) self.preview3d = preview3d.previewPanel(p)
loadButton = wx.Button(p, -1, 'Load STL') loadButton = wx.Button(p, -1, 'Load STL')
sliceButton = wx.Button(p, -1, 'Slice to GCode') sliceButton = wx.Button(p, -1, 'Slice to GCode')

View File

@ -17,13 +17,17 @@ except:
from fabmetheus_utilities.fabmetheus_tools import fabmetheus_interpret from fabmetheus_utilities.fabmetheus_tools import fabmetheus_interpret
from fabmetheus_utilities.vector3 import Vector3 from fabmetheus_utilities.vector3 import Vector3
class myGLCanvas(GLCanvas): class previewPanel(wx.Panel):
def __init__(self, parent): def __init__(self, parent):
GLCanvas.__init__(self, parent,-1) wx.Panel.__init__(self, parent,-1)
wx.EVT_PAINT(self, self.OnPaint)
wx.EVT_SIZE(self, self.OnSize) self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DDKSHADOW))
wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
wx.EVT_MOTION(self, self.OnMouseMotion) self.glCanvas = GLCanvas(self, -1)
wx.EVT_PAINT(self.glCanvas, self.OnPaint)
wx.EVT_SIZE(self.glCanvas, self.OnSize)
wx.EVT_ERASE_BACKGROUND(self.glCanvas, self.OnEraseBackground)
wx.EVT_MOTION(self.glCanvas, self.OnMouseMotion)
self.init = 0 self.init = 0
self.triangleMesh = None self.triangleMesh = None
self.modelDisplayList = None self.modelDisplayList = None
@ -34,21 +38,31 @@ class myGLCanvas(GLCanvas):
self.renderTransparent = False self.renderTransparent = False
self.machineSize = Vector3(210, 210, 200) self.machineSize = Vector3(210, 210, 200)
self.machineCenter = Vector3(105, 105, 0) self.machineCenter = Vector3(105, 105, 0)
configButton = wx.Button(self, -1, '', (3,3), (10,10))
self.Bind(wx.EVT_BUTTON, self.OnConfigClick, configButton) tb = wx.ToolBar( self, -1 )
self.ToolBar = tb
tb.SetToolBitmapSize( ( 21, 21 ) )
transparentButton = wx.Button(tb, -1, "T", size=(21,21))
tb.AddControl(transparentButton)
self.Bind(wx.EVT_BUTTON, self.OnConfigClick, transparentButton)
tb.Realize()
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(tb, 0, flag=wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, border=1)
sizer.Add(self.glCanvas, 1, flag=wx.EXPAND)
self.SetSizer(sizer)
def loadModelFile(self, filename): def loadModelFile(self, filename):
self.modelFilename = filename self.modelFilename = filename
#Do the STL file loading in a background thread so we don't block the UI. #Do the STL file loading in a background thread so we don't block the UI.
thread = threading.Thread(target=self.DoModelLoad) thread = threading.Thread(target=self.DoModelLoad)
thread.setDaemon(True)
thread.start() thread.start()
def loadGCodeFile(self, filename): def loadGCodeFile(self, filename):
self.gcodeFilename = filename self.gcodeFilename = filename
#Do the STL file loading in a background thread so we don't block the UI. #Do the STL file loading in a background thread so we don't block the UI.
thread = threading.Thread(target=self.DoGCodeLoad) thread = threading.Thread(target=self.DoGCodeLoad)
thread.setDaemon(True)
thread.start() thread.start()
def DoModelLoad(self): def DoModelLoad(self):
@ -206,7 +220,7 @@ class myGLCanvas(GLCanvas):
dc.Clear() dc.Clear()
dc.DrawText("No PyOpenGL installation found.\nNo preview window available.", 10, 10) dc.DrawText("No PyOpenGL installation found.\nNo preview window available.", 10, 10)
return return
self.SetCurrent() self.glCanvas.SetCurrent()
self.InitGL() self.InitGL()
self.OnDraw() self.OnDraw()
return return
@ -302,14 +316,15 @@ class myGLCanvas(GLCanvas):
glEnable(GL_LIGHTING) glEnable(GL_LIGHTING)
glCallList(self.modelDisplayList) glCallList(self.modelDisplayList)
self.SwapBuffers() self.glCanvas.SwapBuffers()
return return
def InitGL(self): def InitGL(self):
# set viewing projection # set viewing projection
glMatrixMode(GL_MODELVIEW) glMatrixMode(GL_MODELVIEW)
glLoadIdentity() glLoadIdentity()
glViewport(0,0, self.GetSize().GetWidth(), self.GetSize().GetHeight()) size = self.glCanvas.GetSize()
glViewport(0,0, size.GetWidth(), size.GetHeight())
if self.renderTransparent: if self.renderTransparent:
glLightfv(GL_LIGHT0, GL_DIFFUSE, [0.5, 0.4, 0.3, 1.0]) glLightfv(GL_LIGHT0, GL_DIFFUSE, [0.5, 0.4, 0.3, 1.0])

View File

@ -18,6 +18,7 @@ def getPyPyExe():
pypyExe = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../pypy/pypy.exe")); pypyExe = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../pypy/pypy.exe"));
else: else:
pypyExe = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../pypy/bin/pypy")); pypyExe = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../pypy/bin/pypy"));
print pypyExe
if os.path.exists(pypyExe): if os.path.exists(pypyExe):
return pypyExe return pypyExe
pypyExe = "/bin/pypy"; pypyExe = "/bin/pypy";

View File

@ -11,11 +11,14 @@ The slicing code is the same as Skeinforge. But the UI has been revamped to be..
from __future__ import absolute_import from __future__ import absolute_import
import sys
import platform
from optparse import OptionParser from optparse import OptionParser
from newui import mainWindow
from newui import skeinRun from newui import skeinRun
import sys if platform.python_implementation() != "PyPy":
from newui import mainWindow
__author__ = 'Daid' __author__ = 'Daid'
__credits__ = """ __credits__ = """