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)
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')
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
import platform
import shutil
import glob
+import subprocess
import warnings
try:
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
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
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:
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)
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):
prefDialog.Centre()
prefDialog.Show()
prefDialog.Raise()
- wx.CallAfter(prefDialog.Show)
def OnMachineSettings(self, e):
prefDialog = preferencesDialog.machineSettingsDialog(self)
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)
#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):
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)
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)
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)
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.
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:
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):
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):
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):
"""
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):
self.statsText.SetLabel(info)
if connection.isPrinting() != self._isPrinting:
self._isPrinting = connection.isPrinting()
- preventComputerFromSleeping(self._isPrinting)
+ preventComputerFromSleeping(self, self._isPrinting)
def _updateButtonStates(self):
self._animView = None
self._animZoom = None
self._platformMesh = {}
+ self.glReleaseList = []
self._platformTexture = None
self._isSimpleMode = True
self._printerConnectionManager = printerConnectionManager.PrinterConnectionManager()
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.
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()
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:
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):
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)
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')