chiark / gitweb /
Merge remote-tracking branch 'origin/master' into AO-build
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Tue, 20 Jan 2015 16:55:01 +0000 (11:55 -0500)
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Tue, 20 Jan 2015 16:55:01 +0000 (11:55 -0500)
Conflicts:
Cura/gui/preferencesDialog.py
Cura/util/profile.py

Cura/gui/aboutWindow.py
Cura/gui/app.py
Cura/gui/configBase.py
Cura/gui/mainWindow.py
Cura/gui/preferencesDialog.py
Cura/gui/printWindow.py
Cura/gui/sceneView.py
Cura/gui/splashScreen.py
Cura/util/machineCom.py
Cura/util/profile.py

index e947392d18380f5ca4260ca61940995da2c26c8e..72f76a21253f9ad94409459287918001a7c26236 100644 (file)
@@ -4,8 +4,8 @@ import wx
 import platform
 
 class aboutWindow(wx.Frame):
-       def __init__(self):
-               super(aboutWindow, self).__init__(None, title="About", style = wx.DEFAULT_DIALOG_STYLE)
+       def __init__(self, parent):
+               super(aboutWindow, self).__init__(parent, title="About", style = wx.DEFAULT_DIALOG_STYLE)
 
                wx.EVT_CLOSE(self, self.OnClose)
 
@@ -27,7 +27,7 @@ class aboutWindow(wx.Frame):
                s.Add(wx.StaticText(p, -1, 'Cura LulzBot Edition has been modified and maintained by Aleph Objects, Inc.'))
                s.Add(wx.StaticText(p, -1, 'for use with LulzBot 3D printers.'))
 
-               s.Add(wx.StaticText(p, -1, 'Cura is build with the following components:'), flag=wx.TOP, border=10)
+               s.Add(wx.StaticText(p, -1, 'Cura is built with the following components:'), flag=wx.TOP, border=10)
                self.addComponent('Cura', 'Graphical user interface', 'AGPLv3', 'https://github.com/daid/Cura')
                self.addComponent('CuraEngine', 'GCode Generator', 'AGPLv3', 'https://github.com/Ultimaker/CuraEngine')
                self.addComponent('Clipper', 'Polygon clipping library', 'Boost', 'http://www.angusj.com/delphi/clipper.php')
@@ -43,7 +43,7 @@ class aboutWindow(wx.Frame):
                        self.addComponent('comtypes', 'Library to help with windows taskbar features on Windows 7', 'MIT', 'http://starship.python.net/crew/theller/comtypes/')
                        self.addComponent('EjectMedia', 'Utility to safe-remove SD cards', 'Freeware', 'http://www.uwe-sieber.de/english.html')
                self.addComponent('Pymclevel', 'Python library for reading Minecraft levels.', 'ISC', 'https://github.com/mcedit/pymclevel')
-               s.Add(wx.StaticText(p, -1, "Copyright (C) 2014 Aleph Objects, Inc. - Release under terms of the AGPLv3 License"), flag=wx.TOP, border=10)
+               s.Add(wx.StaticText(p, -1, "Copyright (C) 2014 Aleph Objects, Inc. - Released under terms of the AGPLv3 License"), flag=wx.TOP, border=10)
                s.Add(wx.StaticText(p, -1, "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"))
                #Translations done by:
                #Dutch: Charlotte Jansen
index a0bfd57a6f0f867106d7d4158d34c16a660afb8c..5b86fb008e96c4baa6e20f19e54998622901519f 100644 (file)
@@ -5,6 +5,7 @@ import os
 import platform
 import shutil
 import glob
+import subprocess
 import warnings
 
 try:
@@ -25,7 +26,8 @@ class CuraApp(wx.App):
                self.splash = None
                self.loadFiles = files
 
-               self.Bind(wx.EVT_ACTIVATE_APP, self.OnActivate)
+               if platform.system() == "Darwin":
+                       self.Bind(wx.EVT_ACTIVATE_APP, self.OnActivate)
 
                if sys.platform.startswith('win'):
                        #Check for an already running instance, if another instance is running load files in there
@@ -78,10 +80,9 @@ class CuraApp(wx.App):
                pass
 
        def OnActivate(self, e):
-               if platform.system() == "Darwin":
-                       if e.GetActive():
-                               self.GetTopWindow().Raise()
-                       e.Skip()
+               if e.GetActive():
+                       self.GetTopWindow().Raise()
+               e.Skip()
 
        def Win32SocketListener(self, port):
                import socket
@@ -162,14 +163,12 @@ class CuraApp(wx.App):
                        wx.CallAfter(self.StupidMacOSWorkaround)
 
        def StupidMacOSWorkaround(self):
-               """
-               On MacOS for some magical reason opening new frames does not work until you opened a new modal dialog and closed it.
-               If we do this from software, then, as if by magic, the bug which prevents opening extra frames is gone.
-               """
-               dlg = wx.Dialog(None)
-               wx.PostEvent(dlg, wx.CommandEvent(wx.EVT_CLOSE.typeId))
-               dlg.ShowModal()
-               dlg.Destroy()
+               subprocess.Popen(['osascript', '-e', '''\
+               tell application "System Events"
+               set procName to name of first process whose unix id is %s
+               end tell
+               tell application procName to activate
+               ''' % os.getpid()])
 
 if platform.system() == "Darwin": #Mac magic. Dragons live here. THis sets full screen options.
        try:
index 0c211c845c1f0e2d4d71d08c7d9ffbef6a5e8827..a9bbbea92c933fa97253506df1f0b5e7ed5a4009 100644 (file)
@@ -160,6 +160,7 @@ class SettingRow(object):
                        self.ctrl.Bind(wx.EVT_TEXT, self.OnSettingChange)
                        flag = wx.EXPAND
 
+               self.ctrl.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
                sizer.Add(self.label, (x,y), flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT,border=10)
                sizer.Add(self.ctrl, (x,y+1), flag=wx.ALIGN_BOTTOM|flag)
                sizer.SetRows(x+1)
@@ -175,9 +176,11 @@ class SettingRow(object):
 
        def OnMouseEnter(self, e):
                self.label.SetToolTipString(self.setting.getTooltip())
+               self.ctrl.SetToolTipString(self.setting.getTooltip())
 
        def OnMouseExit(self, e):
                self.label.SetToolTipString('')
+               self.ctrl.SetToolTipString('')
                e.Skip()
 
        def OnSettingChange(self, e):
index c4bbe4cbae599c5536c0fcbda6be8e9f7179da7a..be24fe7dbdeabe75cf6a5474e7c1d9c8b5cfe7a4 100644 (file)
@@ -353,7 +353,6 @@ class mainWindow(wx.Frame):
                prefDialog.Centre()
                prefDialog.Show()
                prefDialog.Raise()
-               wx.CallAfter(prefDialog.Show)
 
        def OnMachineSettings(self, e):
                prefDialog = preferencesDialog.machineSettingsDialog(self)
@@ -572,9 +571,10 @@ class mainWindow(wx.Frame):
                        wx.MessageBox(_("You are running the latest version of Cura!"), _("Awesome!"), wx.ICON_INFORMATION)
 
        def OnAbout(self, e):
-               aboutBox = aboutWindow.aboutWindow()
+               aboutBox = aboutWindow.aboutWindow(self)
                aboutBox.Centre()
                aboutBox.Show()
+               aboutBox.Raise()
 
        def OnClose(self, e):
                profile.saveProfile(profile.getDefaultProfilePath(), True)
@@ -598,7 +598,7 @@ class mainWindow(wx.Frame):
                #HACK: Set the paint function of the glCanvas to nothing so it won't keep refreshing. Which can keep wxWidgets from quiting.
                print "Closing down"
                self.scene.OnPaint = lambda e : e
-               self.scene._engine.cleanup()
+               self.scene.cleanup()
                self.Destroy()
 
        def OnQuit(self, e):
index 54bde5a4fa5ec2a6186b33b1777688b84cc2332c..6148b3b65ed29feb4ae5c4813fbaa82e05ef89b7 100644 (file)
@@ -11,7 +11,7 @@ from Cura.util import resources
 
 class preferencesDialog(wx.Dialog):
        def __init__(self, parent):
-               super(preferencesDialog, self).__init__(None, title="Preferences")
+               super(preferencesDialog, self).__init__(parent, title="Preferences")
 
                wx.EVT_CLOSE(self, self.OnClose)
 
@@ -65,7 +65,7 @@ class preferencesDialog(wx.Dialog):
 
 class machineSettingsDialog(wx.Dialog):
        def __init__(self, parent):
-               super(machineSettingsDialog, self).__init__(None, title="Machine settings")
+               super(machineSettingsDialog, self).__init__(parent, title="Machine settings")
 
                wx.EVT_CLOSE(self, self.OnClose)
 
@@ -86,6 +86,7 @@ class machineSettingsDialog(wx.Dialog):
                        configBase.SettingRow(left, 'machine_width', index=idx)
                        configBase.SettingRow(left, 'machine_depth', index=idx)
                        configBase.SettingRow(left, 'machine_height', index=idx)
+                       configBase.SettingRow(left, 'extruder_z_offset', index=idx)
                        configBase.SettingRow(left, 'extruder_amount', index=idx)
                        configBase.SettingRow(left, 'has_heated_bed', index=idx)
                        configBase.SettingRow(left, 'machine_center_is_zero', index=idx)
index 35be4a8385f1be33c478b6cce3361ecf760f86e3..74be922d84fd95339f53b0c981b25e705109bb49 100644 (file)
@@ -6,10 +6,11 @@ import time
 import sys
 import os
 import ctypes
+import subprocess
 
 #TODO: This does not belong here!
 if sys.platform.startswith('win'):
-       def preventComputerFromSleeping(prevent):
+       def preventComputerFromSleeping(frame, prevent):
                """
                Function used to prevent the computer from going into sleep mode.
                :param prevent: True = Prevent the system from going to sleep from this point on.
@@ -34,7 +35,7 @@ elif sys.platform.startswith('darwin'):
        frameworkPath=objc.pathForFramework("/System/Library/Frameworks/IOKit.framework"),
        globals=globals())
        objc.loadBundleFunctions(bundle, globals(), [("IOPMAssertionCreateWithName", b"i@I@o^I")])
-       def preventComputerFromSleeping(prevent):
+       def preventComputerFromSleeping(frame, prevent):
                if prevent:
                        success, preventComputerFromSleeping.assertionID = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, "Cura is printing", None)
                        if success != kIOReturnSuccess:
@@ -44,8 +45,13 @@ elif sys.platform.startswith('darwin'):
                                IOPMAssertionRelease(preventComputerFromSleeping.assertionID)
                                preventComputerFromSleeping.assertionID = None
 else:
-       def preventComputerFromSleeping(prevent):
-               pass
+       def preventComputerFromSleeping(frame, prevent):
+                if os.path.isfile("/usr/bin/xdg-screensaver"):
+                        try:
+                                cmd = ['xdg-screensaver', 'suspend' if prevent else 'resume', str(frame.GetHandle())]
+                                subprocess.call(cmd)
+                        except:
+                                pass
 
 class printWindowPlugin(wx.Frame):
        def __init__(self, parent, printerConnection, filename):
@@ -252,7 +258,7 @@ class printWindowPlugin(wx.Frame):
                        self._printerConnection.closeActiveConnection()
                self._printerConnection.removeCallback(self._doPrinterConnectionUpdate)
                #TODO: When multiple printer windows are open, closing one will enable sleeping again.
-               preventComputerFromSleeping(False)
+               preventComputerFromSleeping(self, False)
                self.Destroy()
 
        def OnTermEnterLine(self, e):
@@ -355,7 +361,7 @@ class printWindowPlugin(wx.Frame):
                        self.SetTitle(info.replace('\n', ', '))
                if connection.isPrinting() != self._isPrinting:
                        self._isPrinting = connection.isPrinting()
-                       preventComputerFromSleeping(self._isPrinting)
+                       preventComputerFromSleeping(self, self._isPrinting)
 
 class printWindowBasic(wx.Frame):
        """
@@ -449,7 +455,7 @@ class printWindowBasic(wx.Frame):
                        self._printerConnection.closeActiveConnection()
                self._printerConnection.removeCallback(self._doPrinterConnectionUpdate)
                #TODO: When multiple printer windows are open, closing one will enable sleeping again.
-               preventComputerFromSleeping(False)
+               preventComputerFromSleeping(self, False)
                self.Destroy()
 
        def OnConnect(self, e):
@@ -499,7 +505,7 @@ class printWindowBasic(wx.Frame):
                self.statsText.SetLabel(info)
                if connection.isPrinting() != self._isPrinting:
                        self._isPrinting = connection.isPrinting()
-                       preventComputerFromSleeping(self._isPrinting)
+                       preventComputerFromSleeping(self, self._isPrinting)
 
 
        def _updateButtonStates(self):
index 447b5838f5bb5829a165dac9a64763c8f5918db2..48c975d3e68344c7e43f947c1d9c8128524ab12a 100644 (file)
@@ -52,6 +52,7 @@ class SceneView(openglGui.glGuiPanel):
                self._animView = None
                self._animZoom = None
                self._platformMesh = {}
+               self.glReleaseList = []
                self._platformTexture = None
                self._isSimpleMode = True
                self._printerConnectionManager = printerConnectionManager.PrinterConnectionManager()
@@ -120,6 +121,19 @@ class SceneView(openglGui.glGuiPanel):
                self.updateToolButtons()
                self.updateProfileToControls()
 
+       def cleanup(self):
+               # Delete all objects first
+               self.OnDeleteAll(None)
+               self._engine.cleanup()
+               if self._objectShader is not None:
+                       self._objectShader.release()
+               if self._objectLoadShader is not None:
+                       self._objectLoadShader.release()
+               if self._objectOverhangShader is not None:
+                       self._objectOverhangShader.release()
+               for obj in self.glReleaseList:
+                       obj.release()
+
        def loadGCodeFile(self, filename):
                self.OnDeleteAll(None)
                #Cheat the engine results to load a GCode file into it.
index 27463f5fe2e5f26f868552b4199f2a8f0886e31b..44bad77acd2db0cf8c08439ce201776b294b020e 100644 (file)
@@ -19,7 +19,8 @@ class splashScreen(wx.SplashScreen):
 
        def OnClose(self, e):
                if self.callback:
-                               # Avoid calling the callback twice
-                               self.callback()
-                               self.callback = None
+                       # Avoid calling the callback twice
+                       self.callback()
+                       self.callback = None
                wx.CallAfter(self.DoDestroy)
+               e.Skip()
index c09adb36984a7e4e056ac37fde4b884f9b1d5c03..5fe86611c4aacdfe77b14981a1b54bd74c74f0da 100644 (file)
@@ -395,7 +395,10 @@ class MachineCom(object):
                                        t = time.time()
                                        self._heatupWaitTimeLost = t - self._heatupWaitStartTime
                                        self._heatupWaitStartTime = t
-                       elif line.strip() != '' and line.strip() != 'ok' and not line.startswith('Resend:') and not line.startswith('Error:checksum mismatch') and not line.startswith('Error:Line Number is not Last Line Number+1') and line != 'echo:Unknown command:""\n' and self.isOperational():
+                       elif line.strip() != '' and line.strip() != 'ok' and not line.startswith('Resend:') and \
+                                not line.startswith('Error:checksum mismatch') and not line.startswith('Error:Line Number is not Last Line Number+1') and \
+                                not line.startswith('Error:No Checksum with line number') and not line.startswith('Error:No Line Number with checksum') and \
+                                line != 'echo:Unknown command:""\n' and self.isOperational():
                                self._callback.mcMessage(line)
 
                        if self._state == self.STATE_DETECT_BAUDRATE or self._state == self.STATE_DETECT_SERIAL:
@@ -616,7 +619,7 @@ class MachineCom(object):
                self._printSection = 'CUSTOM'
                self._changeState(self.STATE_PRINTING)
                self._printStartTime = time.time()
-               for i in xrange(0, 4):
+               for i in xrange(0, 2):
                        self._sendNext()
        
        def cancelPrint(self):
@@ -626,7 +629,7 @@ class MachineCom(object):
        def setPause(self, pause):
                if not pause and self.isPaused():
                        self._changeState(self.STATE_PRINTING)
-                       for i in xrange(0, 6):
+                       for i in xrange(0, 2):
                                self._sendNext()
                if pause and self.isPrinting():
                        self._changeState(self.STATE_PAUSED)
index 1db26fe6dddd69608479b41252465eb94cd28846..d843c8da7b1cb9ee4f5e121f0df5902fe5d1f41f 100644 (file)
@@ -509,6 +509,8 @@ setting('extruder_offset_x2', '0.0', float, 'machine', 'hidden').setLabel(_("Off
 setting('extruder_offset_y2', '0.0', float, 'machine', 'hidden').setLabel(_("Offset Y"), _("The offset of your tertiary extruder compared to the primary."))
 setting('extruder_offset_x3', '0.0', float, 'machine', 'hidden').setLabel(_("Offset X"), _("The offset of your forth extruder compared to the primary."))
 setting('extruder_offset_y3', '0.0', float, 'machine', 'hidden').setLabel(_("Offset Y"), _("The offset of your forth extruder compared to the primary."))
+setting('extruder_z_offset', '0.0', float, 'machine', 'hidden').setLabel(_("Z-Offset (mm)"), _("This value will be added to the Z coordinate of every line in the output G-Code to compensate for a badly calibrate Z height endstop."))
+
 setting('steps_per_e', '0', float, 'machine', 'hidden').setLabel(_("E-Steps per 1mm filament"), _("Amount of steps per mm filament extrusion. If set to 0 then this value is ignored and the value in your firmware is used."))
 setting('serial_port', 'AUTO', str, 'machine', 'hidden').setLabel(_("Serial port"), _("Serial port to use for communication with the printer"))
 setting('serial_port_auto', '', str, 'machine', 'hidden')