From: daid303 Date: Tue, 6 Nov 2012 07:52:16 +0000 (+0100) Subject: Update on the GL window, better lighting. Upda on the plugin system GUI. Always show... X-Git-Tag: 13.03~209 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=7c7937fde5500a28a6902c44c5c0cd95655f4f90;p=cura.git Update on the GL window, better lighting. Upda on the plugin system GUI. Always show copy-to-SD button, and open preferences if no drive is set. --- diff --git a/Cura/gui/opengl.py b/Cura/gui/opengl.py index 5c8c3d3c..29b3f0c9 100644 --- a/Cura/gui/opengl.py +++ b/Cura/gui/opengl.py @@ -21,7 +21,7 @@ def InitGL(window, view3D, zoom): size = window.GetSize() glViewport(0,0, size.GetWidth(), size.GetHeight()) - glLightfv(GL_LIGHT0, GL_POSITION, [1.0, 1.0, 1.0, 0.0]) + glLightfv(GL_LIGHT0, GL_POSITION, [0.2, 0.2, 1.0, 0.0]) glLightfv(GL_LIGHT1, GL_POSITION, [1.0, 1.0, 1.0, 0.0]) glEnable(GL_RESCALE_NORMAL) @@ -53,7 +53,7 @@ def DrawMachine(machineSize): if profile.getPreference('machine_type') == 'ultimaker': glPushMatrix() glEnable(GL_LIGHTING) - glTranslate(100,120,-285) + glTranslate(100,200,-5) glLightfv(GL_LIGHT0, GL_DIFFUSE, [0.8,0.8,0.8]) glLightfv(GL_LIGHT0, GL_AMBIENT, [0.5,0.5,0.5]) glEnable(GL_BLEND) @@ -62,7 +62,7 @@ def DrawMachine(machineSize): global platformMesh if platformMesh == None: platformMesh = meshLoader.loadMesh(os.path.normpath(os.path.join(os.path.split(__file__)[0], "../images", 'ultimaker_platform.stl'))) - platformMesh.setRotateMirror(0, False, True, False, False, True) + platformMesh.setRotateMirror(0, False, False, False, False, False) DrawMesh(platformMesh) glPopMatrix() @@ -130,7 +130,7 @@ def DrawMachine(machineSize): glVertex3f(min(x+10, machineSize.x), min(y+10, machineSize.y), -0.01) glVertex3f(x, min(y+10, machineSize.y), -0.01) glEnd() - glColor4ub(5/2,171/2,231/2,128) + glColor4ub(5*8/10,171*8/10,231*8/10,128) glBegin(GL_QUADS) for x in xrange(10, int(machineSize.x), 20): for y in xrange(0, int(machineSize.y), 20): @@ -147,7 +147,7 @@ def DrawMachine(machineSize): glEnd() glEnable(GL_CULL_FACE) - glColor4ub(5,171,231,128) + glColor4ub(5,171,231,64) glBegin(GL_QUADS) glVertex3f(0, 0, machineSize.z) glVertex3f(0, machineSize.y, machineSize.z) @@ -155,7 +155,7 @@ def DrawMachine(machineSize): glVertex3f(machineSize.x, 0, machineSize.z) glEnd() - glColor4ub(5,171,231,192) + glColor4ub(5,171,231,96) glBegin(GL_QUADS) glVertex3f(0, 0, 0) glVertex3f(0, 0, machineSize.z) @@ -168,7 +168,7 @@ def DrawMachine(machineSize): glVertex3f(machineSize.x, machineSize.y, machineSize.z) glEnd() - glColor4ub(5,171,231,255) + glColor4ub(5,171,231,128) glBegin(GL_QUADS) glVertex3f(0, 0, machineSize.z) glVertex3f(0, 0, 0) @@ -395,7 +395,7 @@ def DrawGCodeLayer(layer): dist = (v0 - v1).vsize() if dist > 0 and path.layerThickness > 0: extrusionMMperDist = (v1.e - v0.e) / dist - lineWidth = extrusionMMperDist * filamentArea / path.layerThickness / 2 + lineWidth = extrusionMMperDist * filamentArea / path.layerThickness / 2 * v1.extrudeAmountMultiply drawLength += (v0 - v1).vsize() normal = (v0 - v1).cross(util3d.Vector3(0,0,1)) diff --git a/Cura/gui/pluginPanel.py b/Cura/gui/pluginPanel.py index fa0599ad..e659a9ec 100644 --- a/Cura/gui/pluginPanel.py +++ b/Cura/gui/pluginPanel.py @@ -66,12 +66,14 @@ class pluginPanel(wx.Panel): title = wx.StaticText(pluginPanel, -1, plugin['name']) title.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD)) remButton = wx.Button(pluginPanel, -1, 'X', style=wx.BU_EXACTFIT) - s.Add(title, pos=(0,0), span=(1,2), flag=wx.ALIGN_BOTTOM|wx.TOP|wx.LEFT|wx.RIGHT, border=5) - s.Add(remButton, pos=(0,2), span=(1,1), flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.ALIGN_RIGHT, border=5) - s.Add(wx.StaticLine(pluginPanel), pos=(1,0), span=(1,3), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3) + helpButton = wx.Button(pluginPanel, -1, '?', style=wx.BU_EXACTFIT) + s.Add(title, pos=(0,1), span=(1,2), flag=wx.ALIGN_BOTTOM|wx.TOP|wx.LEFT|wx.RIGHT, border=5) + s.Add(helpButton, pos=(0,0), span=(1,1), flag=wx.TOP|wx.LEFT|wx.ALIGN_RIGHT, border=5) + s.Add(remButton, pos=(0,3), span=(1,1), flag=wx.TOP|wx.RIGHT|wx.ALIGN_RIGHT, border=5) + s.Add(wx.StaticLine(pluginPanel), pos=(1,0), span=(1,4), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3) info = wx.StaticText(pluginPanel, -1, plugin['info']) info.Wrap(300) - s.Add(info, pos=(2,0), span=(1,3), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3) + s.Add(info, pos=(2,0), span=(1,4), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3) pluginPanel.paramCtrls = {} i = 0 @@ -81,19 +83,19 @@ class pluginPanel(wx.Panel): value = pluginConfig['params'][param['name']] ctrl = wx.TextCtrl(pluginPanel, -1, value) - s.Add(wx.StaticText(pluginPanel, -1, param['description']), pos=(3+i,0), span=(1,1), flag=wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL,border=3) - s.Add(ctrl, pos=(3+i,2), span=(1,1), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3) + s.Add(wx.StaticText(pluginPanel, -1, param['description']), pos=(3+i,0), span=(1,2), flag=wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL,border=3) + s.Add(ctrl, pos=(3+i,2), span=(1,2), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3) ctrl.Bind(wx.EVT_TEXT, self.OnSettingChange) pluginPanel.paramCtrls[param['name']] = ctrl i += 1 - s.Add(wx.StaticLine(pluginPanel), pos=(3+i,0), span=(1,3), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3) + s.Add(wx.StaticLine(pluginPanel), pos=(3+i,0), span=(1,4), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3) self.Bind(wx.EVT_BUTTON, self.OnRem, remButton) - s.AddGrowableCol(2) + s.AddGrowableCol(1) pluginPanel.SetBackgroundColour(self.GetParent().GetBackgroundColour()) self.pluginEnabledPanel.GetSizer().Add(pluginPanel, flag=wx.EXPAND) self.pluginEnabledPanel.Layout() diff --git a/Cura/gui/preferencesDialog.py b/Cura/gui/preferencesDialog.py index 0fe84e1d..fcd1fbbe 100644 --- a/Cura/gui/preferencesDialog.py +++ b/Cura/gui/preferencesDialog.py @@ -60,8 +60,8 @@ class preferencesDialog(configBase.configWindowBase): c = configBase.SettingRow(right, 'Save profile on slice', 'save_profile', False, 'When slicing save the profile as [stl_file]_profile.ini next to the model.', type = 'preference') configBase.TitleRow(right, 'SD Card settings') - if len(getDrives()) > 1: - c = configBase.SettingRow(right, 'SD card drive', 'sdpath', getDrives(), 'Location of your SD card, when using the copy to SD feature.', type = 'preference') + if len(profile.getSDcardDrives()) > 1: + c = configBase.SettingRow(right, 'SD card drive', 'sdpath', profile.getSDcardDrives(), 'Location of your SD card, when using the copy to SD feature.', type = 'preference') else: c = configBase.SettingRow(right, 'SD card path', 'sdpath', '', 'Location of your SD card, when using the copy to SD feature.', type = 'preference') c = configBase.SettingRow(right, 'Copy to SD with 8.3 names', 'sdshortnames', False, 'Save the gcode files in short filenames, so they are properly shown on the UltiController', type = 'preference') @@ -80,20 +80,3 @@ class preferencesDialog(configBase.configWindowBase): self.MakeModal(False) self.parent.updateProfileToControls() self.Destroy() - -def getDrives(): - drives = [''] - if platform.system() == "Windows": - from ctypes import windll - bitmask = windll.kernel32.GetLogicalDrives() - for letter in string.uppercase: - if bitmask & 1: - drives.append(letter + ':/') - bitmask >>= 1 - if platform.system() == "Darwin": - drives = [] - for volume in glob.glob('/Volumes/*'): - if stat.S_ISLNK(os.lstat(volume).st_mode): - continue - drives.append(volume) - return drives diff --git a/Cura/gui/preview3d.py b/Cura/gui/preview3d.py index c46fac73..54244dd0 100644 --- a/Cura/gui/preview3d.py +++ b/Cura/gui/preview3d.py @@ -64,7 +64,7 @@ class previewPanel(wx.Panel): self.warningPopup.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnHideWarning, self.warningPopup.timer) - self.Bind(wx.EVT_BUTTON, self.OnResetAll, self.warningPopup.yesButton) + self.Bind(wx.EVT_BUTTON, self.OnWarningPopup, self.warningPopup.yesButton) self.Bind(wx.EVT_BUTTON, self.OnHideWarning, self.warningPopup.noButton) parent.Bind(wx.EVT_MOVE, self.OnMove) parent.Bind(wx.EVT_SIZE, self.OnMove) @@ -136,8 +136,9 @@ class previewPanel(wx.Panel): sizer.Add(self.toolbar2, 0, flag=wx.EXPAND|wx.BOTTOM|wx.LEFT|wx.RIGHT, border=1) self.SetSizer(sizer) - def OnMove(self, e): - e.Skip() + def OnMove(self, e = None): + if e != None: + e.Skip() x, y = self.glCanvas.ClientToScreenXY(0, 0) sx, sy = self.glCanvas.GetClientSizeTuple() self.warningPopup.SetPosition((x, y+sy-self.warningPopup.GetSize().height)) @@ -249,8 +250,15 @@ class previewPanel(wx.Panel): if showWarning: if profile.getProfileSettingFloat('model_scale') != 1.0 or profile.getProfileSettingFloat('model_rotate_base') != 0 or profile.getProfileSetting('flip_x') != 'False' or profile.getProfileSetting('flip_y') != 'False' or profile.getProfileSetting('flip_z') != 'False' or profile.getProfileSetting('swap_xz') != 'False' or profile.getProfileSetting('swap_yz') != 'False': - self.warningPopup.Show(True) - self.warningPopup.timer.Start(5000) + self.ShowWarningPopup('Reset scale, rotation and mirror?', self.OnResetAll) + + def ShowWarningPopup(self, text, callback): + self.warningPopup.text.SetLabel(text) + self.warningPopup.callback = callback + self.OnMove() + self.warningPopup.Show(True) + self.warningPopup.timer.Start(5000) + def loadReModelFiles(self, filelist): #Only load this again if the filename matches the file we have already loaded (for auto loading GCode after slicing) @@ -303,7 +311,7 @@ class previewPanel(wx.Panel): def loadProgress(self, progress): pass - def OnResetAll(self, e): + def OnResetAll(self, e = None): profile.putProfileSetting('model_scale', '1.0') profile.putProfileSetting('model_rotate_base', '0') profile.putProfileSetting('flip_x', 'False') @@ -312,8 +320,11 @@ class previewPanel(wx.Panel): profile.putProfileSetting('swap_xz', 'False') profile.putProfileSetting('swap_yz', 'False') self.updateProfileToControls() + + def OnWarningPopup(self, e): self.warningPopup.Show(False) self.warningPopup.timer.Stop() + self.warningPopup.callback() def OnHideWarning(self, e): self.warningPopup.Show(False) @@ -676,7 +687,7 @@ class PreviewGLCanvas(glcanvas.GLCanvas): glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) elif self.viewMode == "Normal": glLightfv(GL_LIGHT0, GL_DIFFUSE, self.objColor[self.parent.objectList.index(obj)]) - glLightfv(GL_LIGHT0, GL_AMBIENT, map(lambda x: x / 5, self.objColor[self.parent.objectList.index(obj)])) + glLightfv(GL_LIGHT0, GL_AMBIENT, map(lambda x: x * 0.4, self.objColor[self.parent.objectList.index(obj)])) glEnable(GL_LIGHTING) self.drawModel(obj) diff --git a/Cura/gui/sliceProgessPanel.py b/Cura/gui/sliceProgessPanel.py index 0cbdc2d3..1500a59d 100644 --- a/Cura/gui/sliceProgessPanel.py +++ b/Cura/gui/sliceProgessPanel.py @@ -4,6 +4,7 @@ import __init__ import wx, sys, os, shutil, math, threading, subprocess, time, re from gui import taskbar +from gui import preferencesDialog from util import profile from util import sliceRun from util import exporer @@ -72,6 +73,14 @@ class sliceProgessPanel(wx.Panel): exporer.openExporer(sliceRun.getExportFilename(self.filelist[0])) def OnCopyToSD(self, e): + if profile.getPreference('sdpath') == '': + wx.MessageBox("You need to configure your SD card drive first before you can copy files to it.\nOpening the preferences now.", 'No SD card drive.', wx.OK | wx.ICON_INFORMATION) + prefDialog = preferencesDialog.preferencesDialog(self.GetParent()) + prefDialog.Centre() + prefDialog.Show(True) + if profile.getPreference('sdpath') == '': + print "No path set" + return exportFilename = sliceRun.getExportFilename(self.filelist[0]) filename = os.path.basename(exportFilename) if profile.getPreference('sdshortnames') == 'True': @@ -98,8 +107,8 @@ class sliceProgessPanel(wx.Panel): self.openFileLocationButton = wx.Button(self, -1, "Open file location") self.Bind(wx.EVT_BUTTON, self.OnOpenFileLocation, self.openFileLocationButton) self.sizer.Add(self.openFileLocationButton, 0) - if profile.getPreference('sdpath') != '': - self.copyToSDButton = wx.Button(self, -1, "To SDCard") + if len(profile.getSDcardDrives()) > 0: + self.copyToSDButton = wx.Button(self, -1, "Copy to SDCard") self.Bind(wx.EVT_BUTTON, self.OnCopyToSD, self.copyToSDButton) self.sizer.Add(self.copyToSDButton, 0) self.showButton = wx.Button(self, -1, "Show result") diff --git a/Cura/images/ultimaker_platform.stl b/Cura/images/ultimaker_platform.stl index 63116857..62d2af96 100644 Binary files a/Cura/images/ultimaker_platform.stl and b/Cura/images/ultimaker_platform.stl differ diff --git a/Cura/util/gcodeInterpreter.py b/Cura/util/gcodeInterpreter.py index e029be26..8d6978bf 100644 --- a/Cura/util/gcodeInterpreter.py +++ b/Cura/util/gcodeInterpreter.py @@ -56,6 +56,7 @@ class gcode(object): totalExtrusion = 0.0 maxExtrusion = 0.0 currentExtruder = 0 + extrudeAmountMultiply = 1.0 totalMoveTimeMinute = 0.0 scale = 1.0 posAbs = True @@ -66,6 +67,7 @@ class gcode(object): currentLayer = [] currentPath = gcodePath('move', pathType, layerThickness, pos.copy()) currentPath.list[0].e = totalExtrusion + currentPath.list[0].extrudeAmountMultiply = extrudeAmountMultiply currentLayer.append(currentPath) for line in gcodeFile: if type(line) is tuple: @@ -141,15 +143,13 @@ class gcode(object): moveType = 'extrude' if e < currentE: moveType = 'retract' - totalExtrusion += e - currentE - currentE = e else: if e > 0: moveType = 'extrude' if e < 0: moveType = 'retract' - totalExtrusion += e - currentE += e + totalExtrusion += e - currentE + currentE = e if totalExtrusion > maxExtrusion: maxExtrusion = totalExtrusion if moveType == 'move' and oldPos.z != pos.z: @@ -161,6 +161,7 @@ class gcode(object): currentLayer.append(currentPath) newPos = pos.copy() newPos.e = totalExtrusion + newPos.extrudeAmountMultiply = extrudeAmountMultiply currentPath.list.append(newPos) elif G == 4: #Delay S = self.getCodeFloat(line, 'S') @@ -242,6 +243,10 @@ class gcode(object): pass elif M == 190: #Set bed temperature & wait pass + elif M == 221: #Extrude amount multiplier + s = self.getCodeFloat(line, 'S') + if s != None: + extrudeAmountMultiply = s / 100.0 else: print "Unknown M code:" + str(M) self.layerList.append(currentLayer) diff --git a/Cura/util/profile.py b/Cura/util/profile.py index b59cd8e5..bbc2982b 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -3,7 +3,7 @@ from __future__ import division #Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module. import __init__ -import os, traceback, math, re, zlib, base64, time, sys, platform, glob +import os, traceback, math, re, zlib, base64, time, sys, platform, glob, string import cPickle as pickle if sys.version_info[0] < 3: import ConfigParser @@ -621,3 +621,20 @@ def runPostProcessingPlugins(gcodefilename): locationInfo = traceback.extract_tb(sys.exc_info()[2])[-1] return "%s: '%s' @ %s:%s:%d" % (str(sys.exc_info()[0].__name__), str(sys.exc_info()[1]), os.path.basename(locationInfo[0]), locationInfo[2], locationInfo[1]) return None + +def getSDcardDrives(): + drives = [''] + if platform.system() == "Windows": + from ctypes import windll + bitmask = windll.kernel32.GetLogicalDrives() + for letter in string.uppercase: + if bitmask & 1: + drives.append(letter + ':/') + bitmask >>= 1 + if platform.system() == "Darwin": + drives = [] + for volume in glob.glob('/Volumes/*'): + if stat.S_ISLNK(os.lstat(volume).st_mode): + continue + drives.append(volume) + return drives