From de6c7c822c8d762680ec2ae56aee579b0e4a4038 Mon Sep 17 00:00:00 2001 From: daid303 Date: Thu, 18 Apr 2013 17:35:56 +0200 Subject: [PATCH] Add a notification if the copy of GCode fails. Fix the refresh bug if there is no event happening no refresh was happening --- Cura/gui/sceneView.py | 16 ++++++++++++---- Cura/gui/util/openglGui.py | 3 +++ Cura/util/profile.py | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Cura/gui/sceneView.py b/Cura/gui/sceneView.py index 59ee0e09..67232d9b 100644 --- a/Cura/gui/sceneView.py +++ b/Cura/gui/sceneView.py @@ -136,8 +136,12 @@ class SceneView(openglGui.glGuiPanel): drive = drives[0] filename = os.path.basename(profile.getPreference('lastFile')) filename = filename[0:filename.rfind('.')] + '.gcode' - shutil.copy(self._slicer.getGCodeFilename(), drive[1] + filename) - self.notification.message("Saved as %s" % (drive[1] + filename)) + try: + shutil.copy(self._slicer.getGCodeFilename(), drive[1] + filename) + except: + self.notification.message("Failed to save to SD card") + else: + self.notification.message("Saved as %s" % (drive[1] + filename)) else: defPath = profile.getPreference('lastFile') defPath = defPath[0:defPath.rfind('.')] + '.gcode' @@ -150,8 +154,12 @@ class SceneView(openglGui.glGuiPanel): filename = dlg.GetPath() dlg.Destroy() - shutil.copy(self._slicer.getGCodeFilename(), filename) - self.notification.message("Saved as %s" % (filename)) + try: + shutil.copy(self._slicer.getGCodeFilename(), filename) + except: + self.notification.message("Failed to save") + else: + self.notification.message("Saved as %s" % (filename)) def OnToolSelect(self, button): if self.rotateToolButton.getSelected(): diff --git a/Cura/gui/util/openglGui.py b/Cura/gui/util/openglGui.py index 7d289cf7..8855b06f 100644 --- a/Cura/gui/util/openglGui.py +++ b/Cura/gui/util/openglGui.py @@ -297,6 +297,9 @@ class glGuiPanel(glcanvas.GLCanvas): pass def QueueRefresh(self): + wx.CallAfter(self._queueRefresh) + + def _queueRefresh(self): self._refreshQueued = True def add(self, ctrl): diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 0727cb93..dd69fc74 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -571,6 +571,8 @@ def calculateLineCount(): def calculateSolidLayerCount(): layerHeight = getProfileSettingFloat('layer_height') solidThickness = getProfileSettingFloat('solid_layer_thickness') + if layerHeight == 0.0: + return 1 return int(math.ceil(solidThickness / layerHeight - 0.0001)) def calculateObjectSizeOffsets(): -- 2.30.2