chiark / gitweb /
Add shortcut keys for load/slice/print.
authordaid303 <daid303@gmail.com>
Mon, 29 Oct 2012 09:10:30 +0000 (10:10 +0100)
committerdaid303 <daid303@gmail.com>
Mon, 29 Oct 2012 09:10:30 +0000 (10:10 +0100)
Cura/gui/mainWindow.py
Cura/gui/simpleMode.py
Cura/gui/sliceProgessPanel.py
Cura/util/profile.py

index 52285b46d17099439b987b1efc16a51ce24d02b9..7f1b11d4d95754092c039ba611218cc7b0be523a 100644 (file)
@@ -1,7 +1,7 @@
 from __future__ import absolute_import
 import __init__
 
-import wx, os, platform, types, webbrowser
+import wx, os, platform, types, webbrowser, shutil, glob
 
 from gui import configBase
 from gui import expertConfig
@@ -27,6 +27,17 @@ from util import meshLoader
 def main():
        #app = wx.App(False)
        if profile.getPreference('machine_type') == 'unknown':
+               if platform.system() == "Darwin":
+                       #Check if we need to copy our examples
+                       exampleFile = os.path.expanduser('~/CuraExamples/UltimakerRobot_support.stl')
+                       if not os.path.isfile(examplePath):
+                               try:
+                                       os.makedirs(os.path.dirname(examplePath))
+                               except:
+                                       pass
+                               for filename in glob.glob(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'example'))):
+                                       shutil.copy(filename, os.path.join(os.path.dirname(examplePath), os.basename(filename)))
+                               profile.putPreference('lastFile', exampleFile)
                configWizard.configWizard()
        if profile.getPreference('startMode') == 'Simple':
                simpleMode.simpleModeWindow()
@@ -207,13 +218,40 @@ class mainWindow(configBase.configWindowBase):
                validators.warningAbove(c, lambda : (float(profile.getProfileSetting('nozzle_size')) * 3.0 / 4.0), "A bottom layer of more then %.2fmm (3/4 nozzle size) usually give bad results and is not recommended.")
                c = configBase.SettingRow(right, "Enable 'skin'", 'enable_skin', False, 'Skin prints the outer lines of the prints twice, each time with half the thickness. This gives the illusion of a higher print quality.')
 
+               #Effects page
+               self.effectList = profile.getEffectsList()
+               if len(self.effectList) > 0:
+                       self.effectPanel = wx.Panel(nb)
+                       sizer = wx.GridBagSizer(2, 2)
+                       self.effectPanel.SetSizer(sizer)
+                       
+                       effectStringList = []
+                       for effect in self.effectList:
+                               effectStringList.append(effect['name'])
+                               
+                       self.listbox = wx.ListBox(self.effectPanel, -1, choices=effectStringList)
+                       title = wx.StaticText(self.effectPanel, -1, "Effects:")
+                       title.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD))
+                       addButton = wx.Button(self.effectPanel, -1, '>', style=wx.BU_EXACTFIT)
+                       remButton = wx.Button(self.effectPanel, -1, '<', style=wx.BU_EXACTFIT)
+                       sizer.Add(self.listbox, (1,0), span=(2,1), border=10, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM)
+                       sizer.Add(title, (0,0), border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.TOP)
+                       sizer.Add(addButton, (1,1), border=5, flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_BOTTOM)
+                       sizer.Add(remButton, (2,1), border=5, flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_TOP)
+                       
+                       sizer.AddGrowableCol(2)
+                       sizer.AddGrowableRow(1)
+                       sizer.AddGrowableRow(2)
+                       nb.AddPage(self.effectPanel, "Effects")
+
+               #Alteration page
                self.alterationPanel = alterationPanel.alterationPanel(nb)
                nb.AddPage(self.alterationPanel, "Start/End-GCode")
 
                # load and slice buttons.
-               loadButton = wx.Button(self, -1, 'Load Model')
-               sliceButton = wx.Button(self, -1, 'Prepare print')
-               printButton = wx.Button(self, -1, 'Print')
+               loadButton = wx.Button(self, -1, '&Load Model')
+               sliceButton = wx.Button(self, -1, 'P&repare print')
+               printButton = wx.Button(self, -1, '&Print')
                self.Bind(wx.EVT_BUTTON, lambda e: self._showModelLoadDialog(1), loadButton)
                self.Bind(wx.EVT_BUTTON, self.OnSlice, sliceButton)
                self.Bind(wx.EVT_BUTTON, self.OnPrint, printButton)
@@ -256,6 +294,11 @@ class mainWindow(configBase.configWindowBase):
 
                self.SetBackgroundColour(nb.GetBackgroundColour())
 
+               self.SetAcceleratorTable(wx.AcceleratorTable([(wx.ACCEL_CTRL, ord('L'), loadButton.GetId()),
+                                                                                                         (wx.ACCEL_CTRL, ord('R'), sliceButton.GetId()),
+                                                                                                         (wx.ACCEL_CTRL, ord('P'), printButton.GetId())
+                                                                                                        ]))
+               
                self.Fit()
                if wx.Display().GetClientArea().GetWidth() < self.GetSize().GetWidth():
                        f = self.GetSize().GetWidth() - wx.Display().GetClientArea().GetWidth()
index 6ddc38be95f73b0941f0c3aca07ffee0306bd4f9..e382ba67cebea4c23282b3cbd55e7a60ecb85e43 100644 (file)
@@ -70,7 +70,7 @@ class simpleModeWindow(configBase.configWindowBase):
                self.printTypeHigh = wx.RadioButton(printTypePanel, -1, 'High quality print')
                self.printTypeJoris = wx.RadioButton(printTypePanel, -1, 'Thin walled cup or vase')
 
-                printMaterialPanel = wx.Panel(configPanel)
+               printMaterialPanel = wx.Panel(configPanel)
                self.printMaterialPLA = wx.RadioButton(printMaterialPanel, -1, 'PLA', style=wx.RB_GROUP)
                self.printMaterialABS = wx.RadioButton(printMaterialPanel, -1, 'ABS')
                self.printMaterialDiameter = wx.TextCtrl(printMaterialPanel, -1, profile.getProfileSetting('filament_diameter'))
@@ -106,9 +106,9 @@ class simpleModeWindow(configBase.configWindowBase):
                sizer.Add(boxsizer, (2,0), flag=wx.EXPAND)
 
                # load and slice buttons.
-               loadButton = wx.Button(self, -1, 'Load Model')
-               sliceButton = wx.Button(self, -1, 'Prepare print')
-               printButton = wx.Button(self, -1, 'Print')
+               loadButton = wx.Button(self, -1, '&Load Model')
+               sliceButton = wx.Button(self, -1, 'P&repare print')
+               printButton = wx.Button(self, -1, '&Print')
                self.Bind(wx.EVT_BUTTON, self.OnLoadModel, loadButton)
                self.Bind(wx.EVT_BUTTON, self.OnSlice, sliceButton)
                self.Bind(wx.EVT_BUTTON, self.OnPrint, printButton)
@@ -137,6 +137,11 @@ class simpleModeWindow(configBase.configWindowBase):
                self.printTypeNormal.SetValue(True)
                self.printMaterialPLA.SetValue(True)
 
+               self.SetAcceleratorTable(wx.AcceleratorTable([(wx.ACCEL_CTRL, ord('L'), loadButton.GetId()),
+                                                                                                         (wx.ACCEL_CTRL, ord('R'), sliceButton.GetId()),
+                                                                                                         (wx.ACCEL_CTRL, ord('P'), printButton.GetId())
+                                                                                                        ]))
+
                self.Fit()
                self.preview3d.Fit()
                self.SetMinSize(self.GetSize())
index 28f7582604595ead45ae9ccbb1bedaa8c5b74200..cc2a34c1f83d8b679605d6ff34e3332849e6aa47 100644 (file)
@@ -168,6 +168,7 @@ class WorkerThread(threading.Thread):
                                if logLine.startswith('Model error('):
                                        gcodefile.write(';%s\n' % (logLine))
                        gcodefile.close()
+                       profile.runPostProcessingEffects(gcodeFilename)
                        self.gcode = gcodeInterpreter.gcode()
                        self.gcode.load(gcodeFilename)
                        profile.replaceGCodeTags(gcodeFilename, self.gcode)
index cb5272bc33749d60769489132233e74d0dda27ae..16d15fec698985fa65a825684a824a4c80a03c64 100644 (file)
@@ -530,3 +530,42 @@ def getAlterationFileContents(filename):
                else:\r
                        alterationContents = ''\r
        return unicode(prefix + re.sub("(.)\{([^\}]*)\}", replaceTagMatch, alterationContents).rstrip() + '\n' + postfix).strip().encode('utf-8')\r
+\r
+def getEffectBasePath():\r
+       return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'post_process'))\r
+\r
+def getEffectsList():\r
+       ret = []\r
+       for filename in glob.glob(os.path.join(getEffectBasePath(), '*.py')):\r
+               filename = os.path.basename(filename)\r
+               if filename.startswith('_'):\r
+                       continue\r
+               with open(os.path.join(getEffectBasePath(), filename), "r") as f:\r
+                       item = {'name': None, 'info': None, 'params': []}\r
+                       for line in f:\r
+                               line = line.strip()\r
+                               if not line.startswith('#'):\r
+                                       break\r
+                               line = line[1:].split(':', 1)\r
+                               if len(line) != 2:\r
+                                       continue\r
+                               if line[0].upper() == 'NAME':\r
+                                       item['name'] = line[1].strip()\r
+                               elif line[0].upper() == 'INFO':\r
+                                       item['info'] = line[1].strip()\r
+                               elif line[0].upper() == 'PARAM':\r
+                                       m = re.match('([a-zA-Z]*)\(([a-zA-Z_]*)\) +(.*)', line[1].strip())\r
+                                       if m != None:\r
+                                               item['params'].append({'name': m.group(1), 'type': m.group(2), 'description': m.group(3)})\r
+                               else:\r
+                                       print "Unknown item in effect meta data: %s %s" % (line[0], line[1])\r
+                       if item['name'] != None:\r
+                               ret.append(item)\r
+       return ret\r
+\r
+def runPostProcessingEffects(filename):\r
+       pass\r
+       #print "runPostProcessingEffects: %s" % (filename)\r
+       \r
+       #pythonFile = os.path.join(getEffectBasePath(), 'embedImage.py')\r
+       #execfile(pythonFile, {'filename': filename})\r