From: daid303 Date: Thu, 25 Apr 2013 07:39:21 +0000 (+0200) Subject: Improve the startup a bit, hide the splashscreen at a better timing and do not reload... X-Git-Tag: 13.05~51 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=976c48f54d27d99876df1ea5fc9659217b301e23;p=cura.git Improve the startup a bit, hide the splashscreen at a better timing and do not reload the last file. --- diff --git a/Cura/cura.py b/Cura/cura.py index 73907642..e796e4b2 100644 --- a/Cura/cura.py +++ b/Cura/cura.py @@ -76,14 +76,8 @@ def main(): scene.add(m) slicer.runSlicer(scene) else: - #Place any unused arguments as last file, so Cura starts with opening those files. - if len(args) > 0: - profile.putPreference('lastFile', ';'.join(args)) - profile.setPluginConfig([]) - - #Do not import anything from Cura.gui before this spot, as the above code also needs to run in pypy. from Cura.gui import app - app.CuraApp().MainLoop() + app.CuraApp(args).MainLoop() if __name__ == '__main__': main() diff --git a/Cura/gui/app.py b/Cura/gui/app.py index c1618de7..02e84b71 100644 --- a/Cura/gui/app.py +++ b/Cura/gui/app.py @@ -11,7 +11,7 @@ import warnings import wx._core class CuraApp(wx.App): - def __init__(self): + def __init__(self, files): if platform.system() == "Windows" and not 'PYCHARM_HOSTED' in os.environ: super(CuraApp, self).__init__(redirect = True, filename = 'output.txt') else: @@ -19,6 +19,7 @@ class CuraApp(wx.App): self.mainWindow = None self.splash = None + self.loadFiles = files if sys.platform.startswith('darwin'): #Do not show a splashscreen on OSX, as by Apple guidelines @@ -29,7 +30,7 @@ class CuraApp(wx.App): def MacOpenFile(self, path): try: - self.mainWindow._loadModels([path]) + self.mainWindow.OnDropFiles([path]) except Exception as e: warnings.warn("File at {p} cannot be read: {e}".format(p=path, e=str(e))) @@ -44,7 +45,9 @@ class CuraApp(wx.App): #If we haven't run it before, run the configuration wizard. if profile.getPreference('machine_type') == 'unknown': - if platform.system() == "Darwin": + if platform.system() == "Windows": + exampleFile = os.path.normpath(os.path.join(resources.resourceBasePath, 'example', 'UltimakerRobot_support.stl')) + else: #Check if we need to copy our examples exampleFile = os.path.expanduser('~/CuraExamples/UltimakerRobot_support.stl') if not os.path.isfile(exampleFile): @@ -54,19 +57,24 @@ class CuraApp(wx.App): pass for filename in glob.glob(os.path.normpath(os.path.join(resources.resourceBasePath, 'example', '*.*'))): shutil.copy(filename, os.path.join(os.path.dirname(exampleFile), os.path.basename(filename))) - profile.putPreference('lastFile', exampleFile) + self.loadFiles = [exampleFile] + if self.splash is not None: + self.splash.Show(False) configWizard.configWizard() - #Hide the splashscreen before showing the main window. - if self.splash is not None: - self.splash.Show(False) if profile.getPreference('check_for_updates') == 'True': newVersion = version.checkForNewerVersion() if newVersion is not None: + if self.splash is not None: + self.splash.Show(False) if wx.MessageBox('A new version of Cura is available, would you like to download?', 'New version available', wx.YES_NO | wx.ICON_INFORMATION) == wx.YES: webbrowser.open(newVersion) return self.mainWindow = mainWindow.mainWindow() + if self.splash is not None: + self.splash.Show(False) + self.mainWindow.Show() + self.mainWindow.OnDropFiles(self.loadFiles) setFullScreenCapable(self.mainWindow) diff --git a/Cura/gui/mainWindow.py b/Cura/gui/mainWindow.py index 3aeadb70..f2790865 100644 --- a/Cura/gui/mainWindow.py +++ b/Cura/gui/mainWindow.py @@ -141,11 +141,6 @@ class mainWindow(wx.Frame): self.menubar.Append(helpMenu, 'Help') self.SetMenuBar(self.menubar) - if profile.getPreference('lastFile') != '': - self.filelist = profile.getPreference('lastFile').split(';') - else: - self.filelist = [] - self.splitter = wx.SplitterWindow(self, style = wx.SP_3D | wx.SP_LIVE_UPDATE) self.leftPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) self.rightPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) @@ -175,13 +170,6 @@ class mainWindow(wx.Frame): sizer.Layout() self.sizer = sizer - if len(self.filelist) > 0: - self.scene.loadScene(self.filelist) - - # Update the Model MRU - for idx in xrange(0, len(self.filelist)): - self.addToModelMRU(self.filelist[idx]) - self.updateProfileToControls() self.SetBackgroundColour(self.normalSettingsPanel.GetBackgroundColour()) @@ -226,8 +214,6 @@ class mainWindow(wx.Frame): self.updateSliceMode() - self.Show(True) - def updateSliceMode(self): isSimple = profile.getPreference('startMode') == 'Simple' diff --git a/Cura/gui/sceneView.py b/Cura/gui/sceneView.py index cfde7ff2..be6cf6df 100644 --- a/Cura/gui/sceneView.py +++ b/Cura/gui/sceneView.py @@ -362,6 +362,9 @@ class SceneView(openglGui.glGuiPanel): self.glReleaseList.append(vbo) self._gcodeVBOs = [] if ready: + print self._slicer.getFilamentAmount() + print self._slicer.getPrintTime() + print self._slicer.getFilamentCost() self._gcode = gcodeInterpreter.gcode() self._gcode.progressCallback = self._gcodeLoadCallback self._thread = threading.Thread(target=self._loadGCode) diff --git a/Cura/util/sliceEngine.py b/Cura/util/sliceEngine.py index 348822ca..10d697fd 100644 --- a/Cura/util/sliceEngine.py +++ b/Cura/util/sliceEngine.py @@ -1,5 +1,6 @@ import subprocess import time +import math import numpy import os import warnings @@ -35,6 +36,8 @@ class Slicer(object): self._progressSteps = ['inset', 'skin', 'export'] self._objCount = 0 self._sliceLog = [] + self._printTimeSeconds = None + self._filamentMM = None def cleanup(self): self.abortSlicer() @@ -61,6 +64,29 @@ class Slicer(object): def getSliceLog(self): return self._sliceLog + def getFilamentWeight(self): + #Calculates the weight of the filament in kg + radius = float(profile.getProfileSetting('filament_diameter')) / 2 + volumeM3 = (self._filamentMM * (math.pi * radius * radius)) / (1000*1000*1000) + return volumeM3 * profile.getPreferenceFloat('filament_physical_density') + + def getFilamentCost(self): + cost_kg = profile.getPreferenceFloat('filament_cost_kg') + cost_meter = profile.getPreferenceFloat('filament_cost_meter') + if cost_kg > 0.0 and cost_meter > 0.0: + return "%.2f / %.2f" % (self.getFilamentWeight() * cost_kg, self._filamentMM / 1000.0 * cost_meter) + elif cost_kg > 0.0: + return "%.2f" % (self.getFilamentWeight() * cost_kg) + elif cost_meter > 0.0: + return "%.2f" % (self._filamentMM / 1000.0 * cost_meter) + return None + + def getPrintTime(self): + return '%02d:%02d' % (int(self._printTimeSeconds / 60 / 60), int(self._printTimeSeconds / 60) % 60) + + def getFilamentAmount(self): + return '%0.2fm' % (float(self._filamentMM) / 1000.0) + def runSlicer(self, scene): self.abortSlicer() self._callback(0.0, False) @@ -118,6 +144,9 @@ class Slicer(object): def _watchProcess(self): self._callback(0.0, False) self._sliceLog = [] + self._printTimeSeconds = None + self._filamentMM = None + line = self._process.stdout.readline() objectNr = 0 while len(line): @@ -137,6 +166,10 @@ class Slicer(object): self._callback(progressValue, False) except: pass + elif line.startswith('Print time:'): + self._printTimeSeconds = int(line.split(':')[1].strip()) + elif line.startswith('Filament:'): + self._filamentMM = int(line.split(':')[1].strip()) else: self._sliceLog.append(line.strip()) line = self._process.stdout.readline()