chiark / gitweb /
Merge tag '14.12' into upstream lulzbot-14.12-rc1
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Thu, 15 Jan 2015 19:19:24 +0000 (14:19 -0500)
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Thu, 15 Jan 2015 19:19:24 +0000 (14:19 -0500)
Conflicts:
Cura/gui/app.py
Cura/gui/configWizard.py
Cura/gui/firmwareInstall.py
Cura/util/bigDataStorage.py
Cura/util/profile.py
package.sh

1  2 
Cura/gui/printWindow.py

diff --combined Cura/gui/printWindow.py
index eb2eb250b0c06e3b126141ce719d97a34c4b349e,5f3cb0637c904e215bf136446338ddca21c258c5..6356df6491486bdc8cb380da8fbf6dd4f347dd80
@@@ -17,34 -17,15 +17,34 @@@ if sys.platform.startswith('win')
                """
                ES_CONTINUOUS = 0x80000000
                ES_SYSTEM_REQUIRED = 0x00000001
 +              ES_AWAYMODE_REQUIRED = 0x00000040
                #SetThreadExecutionState returns 0 when failed, which is ignored. The function should be supported from windows XP and up.
                if prevent:
 -                      ctypes.windll.kernel32.SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED)
 +                      # For Vista and up we use ES_AWAYMODE_REQUIRED to prevent a print from failing if the PC does go to sleep
 +                      # As it's not supported on XP, we catch the error and fallback to using ES_SYSTEM_REQUIRED only
 +                      if ctypes.windll.kernel32.SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED) == 0:
 +                              ctypes.windll.kernel32.SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED)
                else:
                        ctypes.windll.kernel32.SetThreadExecutionState(ES_CONTINUOUS)
  
 +elif sys.platform.startswith('darwin'):
 +      import objc
 +      bundle = objc.initFrameworkWrapper("IOKit",
 +      frameworkIdentifier="com.apple.iokit",
 +      frameworkPath=objc.pathForFramework("/System/Library/Frameworks/IOKit.framework"),
 +      globals=globals())
 +      objc.loadBundleFunctions(bundle, globals(), [("IOPMAssertionCreateWithName", b"i@I@o^I")])
 +      def preventComputerFromSleeping(prevent):
 +              if prevent:
 +                      success, preventComputerFromSleeping.assertionID = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, "Cura is printing", None)
 +                      if success != kIOReturnSuccess:
 +                              preventComputerFromSleeping.assertionID = None
 +              else:
 +                      if preventComputerFromSleeping.assertionID is not None:
 +                              IOPMAssertionRelease(preventComputerFromSleeping.assertionID)
 +                              preventComputerFromSleeping.assertionID = None
  else:
        def preventComputerFromSleeping(prevent):
 -              #No preventComputerFromSleeping for MacOS and Linux yet.
                pass
  
  class printWindowPlugin(wx.Frame):
@@@ -63,7 -44,6 +63,7 @@@
                self._tempGraph = None
                self._infoText = None
                self._lastUpdateTime = time.time()
 +              self._isPrinting = False
  
                variables = {
                        'setImage': self.script_setImage,
@@@ -73,7 -53,6 +73,7 @@@
                        'addProgressbar': self.script_addProgressbar,
                        'addButton': self.script_addButton,
                        'addSpinner': self.script_addSpinner,
 +                      'addTextButton': self.script_addTextButton,
  
                        'sendGCode': self.script_sendGCode,
                        'connect': self.script_connect,
@@@ -95,6 -74,7 +95,6 @@@
  
                if self._printerConnection.hasActiveConnection() and not self._printerConnection.isActiveConnectionOpen():
                        self._printerConnection.openActiveConnection()
 -              preventComputerFromSleeping(True)
  
        def script_setImage(self, guiImage, mapImage):
                self._backgroundImage = wx.BitmapFromImage(wx.Image(os.path.join(self._basePath, guiImage)))
                x, y, w, h = self._getColoredRect(r, g, b)
                if x < 0:
                        return
 +
 +              def run_command(spinner):
 +                      value = spinner.GetValue()
 +                      print "Value (%s) and (%s)" % (spinner.last_value, value)
 +                      if spinner.last_value != '' and value != 0:
 +                              spinner.command(spinner.data % value)
 +                              spinner.last_value = value
 +
                spinner = wx.SpinCtrl(self, -1, style=wx.TE_PROCESS_ENTER)
                spinner.SetRange(0, 300)
                spinner.SetPosition((x, y))
                spinner.SetSize((w, h))
 +              spinner.SetValue(0)
                spinner.command = command
                spinner.data = data
 +              spinner.last_value = ''
                self._buttonList.append(spinner)
 -              self.Bind(wx.EVT_SPINCTRL, lambda e: command(data % (spinner.GetValue())), spinner)
 +              self.Bind(wx.EVT_SPINCTRL, lambda e: run_command(spinner), spinner)
 +
 +      def script_addTextButton(self, r_text, g_text, b_text, r_button, g_button, b_button, button_text, command, data):
 +              x_text, y_text, w_text, h_text = self._getColoredRect(r_text, g_text, b_text)
 +              if x_text < 0:
 +                      return
 +              x_button, y_button, w_button, h_button = self._getColoredRect(r_button, g_button, b_button)
 +              if x_button < 0:
 +                      return
 +              from wx.lib.intctrl import IntCtrl
 +              text = IntCtrl(self, -1)
 +              text.SetBounds(0, 300)
 +              text.SetPosition((x_text, y_text))
 +              text.SetSize((w_text, h_text))
 +              
 +              button = wx.Button(self, -1, _(button_text))
 +              button.SetPosition((x_button, y_button))
 +              button.SetSize((w_button, h_button))
 +              button.command = command
 +              button.data = data
 +              self._buttonList.append(button)
 +              self.Bind(wx.EVT_BUTTON, lambda e: command(data % text.GetValue()), button)
  
        def _getColoredRect(self, r, g, b):
                for x in xrange(0, self._mapImage.GetWidth()):
                        self._infoText.SetLabel(info)
                else:
                        self.SetTitle(info.replace('\n', ', '))
 +              if connection.isPrinting() != self._isPrinting:
 +                      self._isPrinting = connection.isPrinting()
 +                      preventComputerFromSleeping(self._isPrinting)
  
  class printWindowBasic(wx.Frame):
        """
                super(printWindowBasic, self).__init__(parent, -1, style=wx.CLOSE_BOX|wx.CLIP_CHILDREN|wx.CAPTION|wx.SYSTEM_MENU|wx.FRAME_TOOL_WINDOW|wx.FRAME_FLOAT_ON_PARENT, title=_("Printing on %s") % (printerConnection.getName()))
                self._printerConnection = printerConnection
                self._lastUpdateTime = 0
 +              self._isPrinting = False
  
                self.SetSizer(wx.BoxSizer())
                self.panel = wx.Panel(self)
  
                if self._printerConnection.hasActiveConnection() and not self._printerConnection.isActiveConnectionOpen():
                        self._printerConnection.openActiveConnection()
 -              preventComputerFromSleeping(True)
  
        def OnPowerWarningChange(self, e):
                type = self.powerManagement.get_providing_power_source_type()
                        info += ' Bed: %d' % (self._printerConnection.getBedTemperature())
                info += '\n\n'
                self.statsText.SetLabel(info)
 +              if connection.isPrinting() != self._isPrinting:
 +                      self._isPrinting = connection.isPrinting()
 +                      preventComputerFromSleeping(self._isPrinting)
 +
 +
++      def _addTermLog(self, msg):
++              pass
        def _addTermLog(self, msg):
                pass
  
@@@ -573,10 -515,10 +576,10 @@@ class TemperatureGraph(wx.Panel)
                                for n in xrange(0, min(len(t0), len(temp))):
                                        t = float(x - x0) / float(x1 - x0 + 1) * (temp[n] - t0[n]) + t0[n]
                                        dc.SetPen(tempPenBG)
 -                                      dc.DrawLine(x, h, x, h - (t * h / 300))
 +                                      dc.DrawLine(x, h, x, h - (t * h / 350))
                                bt = float(x - x0) / float(x1 - x0 + 1) * (bedTemp - bt0) + bt0
                                dc.SetPen(bedTempPenBG)
 -                              dc.DrawLine(x, h, x, h - (bt * h / 300))
 +                              dc.DrawLine(x, h, x, h - (bt * h / 350))
                        t0 = temp
                        bt0 = bedTemp
                        tSP0 = tempSP
                        dc.SetPen(bgLinePen)
                        dc.DrawLine(x, 0, x, h)
                tmpNr = 0
 -              for y in xrange(h - 1, 0, -h * 50 / 300):
 +              for y in xrange(h - 1, 0, -h * 50 / 350):
                        dc.SetPen(bgLinePen)
                        dc.DrawLine(0, y, w, y)
                        dc.DrawText(str(tmpNr), 0, y - dc.GetFont().GetPixelSize().GetHeight())
                                        t = float(x - x0) / float(x1 - x0 + 1) * (temp[n] - t0[n]) + t0[n]
                                        tSP = float(x - x0) / float(x1 - x0 + 1) * (tempSP[n] - tSP0[n]) + tSP0[n]
                                        dc.SetPen(tempSPPen)
 -                                      dc.DrawPoint(x, h - (tSP * h / 300))
 +                                      dc.DrawPoint(x, h - (tSP * h / 350))
                                        dc.SetPen(tempPen)
 -                                      dc.DrawPoint(x, h - (t * h / 300))
 +                                      dc.DrawPoint(x, h - (t * h / 350))
                                bt = float(x - x0) / float(x1 - x0 + 1) * (bedTemp - bt0) + bt0
                                btSP = float(x - x0) / float(x1 - x0 + 1) * (bedTempSP - btSP0) + btSP0
                                dc.SetPen(bedTempSPPen)
 -                              dc.DrawPoint(x, h - (btSP * h / 300))
 +                              dc.DrawPoint(x, h - (btSP * h / 350))
                                dc.SetPen(bedTempPen)
 -                              dc.DrawPoint(x, h - (bt * h / 300))
 +                              dc.DrawPoint(x, h - (bt * h / 350))
                        t0 = temp
                        bt0 = bedTemp
                        tSP0 = tempSP
  
  class LogWindow(wx.Frame):
        def __init__(self, logText):
 -              super(LogWindow, self).__init__(None, title="Error log")
 +              super(LogWindow, self).__init__(None, title=_("Error log"))
                self.textBox = wx.TextCtrl(self, -1, logText, style=wx.TE_MULTILINE | wx.TE_DONTWRAP | wx.TE_READONLY)
                self.SetSize((500, 400))
                self.Show(True)