chiark / gitweb /
Update on the GL window, better lighting. Upda on the plugin system GUI. Always show...
authordaid303 <daid303@gmail.com>
Tue, 6 Nov 2012 07:52:16 +0000 (08:52 +0100)
committerdaid303 <daid303@gmail.com>
Tue, 6 Nov 2012 07:52:16 +0000 (08:52 +0100)
Cura/gui/opengl.py
Cura/gui/pluginPanel.py
Cura/gui/preferencesDialog.py
Cura/gui/preview3d.py
Cura/gui/sliceProgessPanel.py
Cura/images/ultimaker_platform.stl
Cura/util/gcodeInterpreter.py
Cura/util/profile.py

index 5c8c3d3cf75ecda14869d95a2a0c0ed63f387395..29b3f0c909adcb5509240c2a58ce2509ff372f8a 100644 (file)
@@ -21,7 +21,7 @@ def InitGL(window, view3D, zoom):
        size = window.GetSize()\r
        glViewport(0,0, size.GetWidth(), size.GetHeight())\r
        \r
-       glLightfv(GL_LIGHT0, GL_POSITION, [1.0, 1.0, 1.0, 0.0])\r
+       glLightfv(GL_LIGHT0, GL_POSITION, [0.2, 0.2, 1.0, 0.0])\r
        glLightfv(GL_LIGHT1, GL_POSITION, [1.0, 1.0, 1.0, 0.0])\r
 \r
        glEnable(GL_RESCALE_NORMAL)\r
@@ -53,7 +53,7 @@ def DrawMachine(machineSize):
        if profile.getPreference('machine_type') == 'ultimaker':\r
                glPushMatrix()\r
                glEnable(GL_LIGHTING)\r
-               glTranslate(100,120,-285)\r
+               glTranslate(100,200,-5)\r
                glLightfv(GL_LIGHT0, GL_DIFFUSE, [0.8,0.8,0.8])\r
                glLightfv(GL_LIGHT0, GL_AMBIENT, [0.5,0.5,0.5])\r
                glEnable(GL_BLEND)\r
@@ -62,7 +62,7 @@ def DrawMachine(machineSize):
                global platformMesh\r
                if platformMesh == None:\r
                        platformMesh = meshLoader.loadMesh(os.path.normpath(os.path.join(os.path.split(__file__)[0], "../images", 'ultimaker_platform.stl')))\r
-                       platformMesh.setRotateMirror(0, False, True, False, False, True)\r
+                       platformMesh.setRotateMirror(0, False, False, False, False, False)\r
                \r
                DrawMesh(platformMesh)\r
                glPopMatrix()\r
@@ -130,7 +130,7 @@ def DrawMachine(machineSize):
                                glVertex3f(min(x+10, machineSize.x), min(y+10, machineSize.y), -0.01)\r
                                glVertex3f(x, min(y+10, machineSize.y), -0.01)\r
                glEnd()\r
-               glColor4ub(5/2,171/2,231/2,128)\r
+               glColor4ub(5*8/10,171*8/10,231*8/10,128)\r
                glBegin(GL_QUADS)\r
                for x in xrange(10, int(machineSize.x), 20):\r
                        for y in xrange(0, int(machineSize.y), 20):\r
@@ -147,7 +147,7 @@ def DrawMachine(machineSize):
                glEnd()\r
                glEnable(GL_CULL_FACE)\r
 \r
-               glColor4ub(5,171,231,128)\r
+               glColor4ub(5,171,231,64)\r
                glBegin(GL_QUADS)\r
                glVertex3f(0, 0, machineSize.z)\r
                glVertex3f(0, machineSize.y, machineSize.z)\r
@@ -155,7 +155,7 @@ def DrawMachine(machineSize):
                glVertex3f(machineSize.x, 0, machineSize.z)\r
                glEnd()\r
                \r
-               glColor4ub(5,171,231,192)\r
+               glColor4ub(5,171,231,96)\r
                glBegin(GL_QUADS)\r
                glVertex3f(0, 0, 0)\r
                glVertex3f(0, 0, machineSize.z)\r
@@ -168,7 +168,7 @@ def DrawMachine(machineSize):
                glVertex3f(machineSize.x, machineSize.y, machineSize.z)\r
                glEnd()\r
 \r
-               glColor4ub(5,171,231,255)\r
+               glColor4ub(5,171,231,128)\r
                glBegin(GL_QUADS)\r
                glVertex3f(0, 0, machineSize.z)\r
                glVertex3f(0, 0, 0)\r
@@ -395,7 +395,7 @@ def DrawGCodeLayer(layer):
                                dist = (v0 - v1).vsize()\r
                                if dist > 0 and path.layerThickness > 0:\r
                                        extrusionMMperDist = (v1.e - v0.e) / dist\r
-                                       lineWidth = extrusionMMperDist * filamentArea / path.layerThickness / 2\r
+                                       lineWidth = extrusionMMperDist * filamentArea / path.layerThickness / 2 * v1.extrudeAmountMultiply\r
 \r
                                drawLength += (v0 - v1).vsize()\r
                                normal = (v0 - v1).cross(util3d.Vector3(0,0,1))\r
index fa0599ad2213cd3d34846a4b7fc4e12518b4e909..e659a9ecb4718c9d75c333fa94df6a693028ece1 100644 (file)
@@ -66,12 +66,14 @@ class pluginPanel(wx.Panel):
                title = wx.StaticText(pluginPanel, -1, plugin['name'])
                title.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD))
                remButton = wx.Button(pluginPanel, -1, 'X', style=wx.BU_EXACTFIT)
-               s.Add(title, pos=(0,0), span=(1,2), flag=wx.ALIGN_BOTTOM|wx.TOP|wx.LEFT|wx.RIGHT, border=5)
-               s.Add(remButton, pos=(0,2), span=(1,1), flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.ALIGN_RIGHT, border=5)
-               s.Add(wx.StaticLine(pluginPanel), pos=(1,0), span=(1,3), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3)
+               helpButton = wx.Button(pluginPanel, -1, '?', style=wx.BU_EXACTFIT)
+               s.Add(title, pos=(0,1), span=(1,2), flag=wx.ALIGN_BOTTOM|wx.TOP|wx.LEFT|wx.RIGHT, border=5)
+               s.Add(helpButton, pos=(0,0), span=(1,1), flag=wx.TOP|wx.LEFT|wx.ALIGN_RIGHT, border=5)
+               s.Add(remButton, pos=(0,3), span=(1,1), flag=wx.TOP|wx.RIGHT|wx.ALIGN_RIGHT, border=5)
+               s.Add(wx.StaticLine(pluginPanel), pos=(1,0), span=(1,4), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3)
                info = wx.StaticText(pluginPanel, -1, plugin['info'])
                info.Wrap(300)
-               s.Add(info, pos=(2,0), span=(1,3), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3)
+               s.Add(info, pos=(2,0), span=(1,4), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3)
                
                pluginPanel.paramCtrls = {}
                i = 0
@@ -81,19 +83,19 @@ class pluginPanel(wx.Panel):
                                value = pluginConfig['params'][param['name']]
                        
                        ctrl = wx.TextCtrl(pluginPanel, -1, value)
-                       s.Add(wx.StaticText(pluginPanel, -1, param['description']), pos=(3+i,0), span=(1,1), flag=wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL,border=3)
-                       s.Add(ctrl, pos=(3+i,2), span=(1,1), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3)
+                       s.Add(wx.StaticText(pluginPanel, -1, param['description']), pos=(3+i,0), span=(1,2), flag=wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL,border=3)
+                       s.Add(ctrl, pos=(3+i,2), span=(1,2), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3)
 
                        ctrl.Bind(wx.EVT_TEXT, self.OnSettingChange)
                        
                        pluginPanel.paramCtrls[param['name']] = ctrl
                        
                        i += 1
-               s.Add(wx.StaticLine(pluginPanel), pos=(3+i,0), span=(1,3), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3)
+               s.Add(wx.StaticLine(pluginPanel), pos=(3+i,0), span=(1,4), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3)
 
                self.Bind(wx.EVT_BUTTON, self.OnRem, remButton)
 
-               s.AddGrowableCol(2)
+               s.AddGrowableCol(1)
                pluginPanel.SetBackgroundColour(self.GetParent().GetBackgroundColour())
                self.pluginEnabledPanel.GetSizer().Add(pluginPanel, flag=wx.EXPAND)
                self.pluginEnabledPanel.Layout()
index 0fe84e1d7d80a41a5de6351621b1f5d909cd0daf..fcd1fbbe4c6fa3f27cd815bd4b2d0230fbea1a4d 100644 (file)
@@ -60,8 +60,8 @@ class preferencesDialog(configBase.configWindowBase):
                c = configBase.SettingRow(right, 'Save profile on slice', 'save_profile', False, 'When slicing save the profile as [stl_file]_profile.ini next to the model.', type = 'preference')\r
 \r
                configBase.TitleRow(right, 'SD Card settings')\r
-               if len(getDrives()) > 1:\r
-                       c = configBase.SettingRow(right, 'SD card drive', 'sdpath', getDrives(), 'Location of your SD card, when using the copy to SD feature.', type = 'preference')\r
+               if len(profile.getSDcardDrives()) > 1:\r
+                       c = configBase.SettingRow(right, 'SD card drive', 'sdpath', profile.getSDcardDrives(), 'Location of your SD card, when using the copy to SD feature.', type = 'preference')\r
                else:\r
                        c = configBase.SettingRow(right, 'SD card path', 'sdpath', '', 'Location of your SD card, when using the copy to SD feature.', type = 'preference')\r
                c = configBase.SettingRow(right, 'Copy to SD with 8.3 names', 'sdshortnames', False, 'Save the gcode files in short filenames, so they are properly shown on the UltiController', type = 'preference')\r
@@ -80,20 +80,3 @@ class preferencesDialog(configBase.configWindowBase):
                self.MakeModal(False)\r
                self.parent.updateProfileToControls()\r
                self.Destroy()\r
-\r
-def getDrives():\r
-       drives = ['']\r
-       if platform.system() == "Windows":\r
-               from ctypes import windll\r
-               bitmask = windll.kernel32.GetLogicalDrives()\r
-               for letter in string.uppercase:\r
-                       if bitmask & 1:\r
-                               drives.append(letter + ':/')\r
-                       bitmask >>= 1\r
-       if platform.system() == "Darwin":\r
-               drives = []\r
-               for volume in glob.glob('/Volumes/*'):\r
-                       if stat.S_ISLNK(os.lstat(volume).st_mode):\r
-                               continue\r
-                       drives.append(volume)\r
-       return drives\r
index c46fac73e97240931d32abb7e89e73947c9c1d9e..54244dd0fb6b092d19a60aea975fe26eeac4fb63 100644 (file)
@@ -64,7 +64,7 @@ class previewPanel(wx.Panel):
                self.warningPopup.timer = wx.Timer(self)\r
                self.Bind(wx.EVT_TIMER, self.OnHideWarning, self.warningPopup.timer)\r
                \r
-               self.Bind(wx.EVT_BUTTON, self.OnResetAll, self.warningPopup.yesButton)\r
+               self.Bind(wx.EVT_BUTTON, self.OnWarningPopup, self.warningPopup.yesButton)\r
                self.Bind(wx.EVT_BUTTON, self.OnHideWarning, self.warningPopup.noButton)\r
                parent.Bind(wx.EVT_MOVE, self.OnMove)\r
                parent.Bind(wx.EVT_SIZE, self.OnMove)\r
@@ -136,8 +136,9 @@ class previewPanel(wx.Panel):
                sizer.Add(self.toolbar2, 0, flag=wx.EXPAND|wx.BOTTOM|wx.LEFT|wx.RIGHT, border=1)\r
                self.SetSizer(sizer)\r
        \r
-       def OnMove(self, e):\r
-               e.Skip()\r
+       def OnMove(self, e = None):\r
+               if e != None:\r
+                       e.Skip()\r
                x, y = self.glCanvas.ClientToScreenXY(0, 0)\r
                sx, sy = self.glCanvas.GetClientSizeTuple()\r
                self.warningPopup.SetPosition((x, y+sy-self.warningPopup.GetSize().height))\r
@@ -249,8 +250,15 @@ class previewPanel(wx.Panel):
                \r
                if showWarning:\r
                        if profile.getProfileSettingFloat('model_scale') != 1.0 or profile.getProfileSettingFloat('model_rotate_base') != 0 or profile.getProfileSetting('flip_x') != 'False' or profile.getProfileSetting('flip_y') != 'False' or profile.getProfileSetting('flip_z') != 'False' or profile.getProfileSetting('swap_xz') != 'False' or profile.getProfileSetting('swap_yz') != 'False':\r
-                               self.warningPopup.Show(True)\r
-                               self.warningPopup.timer.Start(5000)\r
+                               self.ShowWarningPopup('Reset scale, rotation and mirror?', self.OnResetAll)\r
+       \r
+       def ShowWarningPopup(self, text, callback):\r
+               self.warningPopup.text.SetLabel(text)\r
+               self.warningPopup.callback = callback\r
+               self.OnMove()\r
+               self.warningPopup.Show(True)\r
+               self.warningPopup.timer.Start(5000)\r
+\r
        \r
        def loadReModelFiles(self, filelist):\r
                #Only load this again if the filename matches the file we have already loaded (for auto loading GCode after slicing)\r
@@ -303,7 +311,7 @@ class previewPanel(wx.Panel):
        def loadProgress(self, progress):\r
                pass\r
 \r
-       def OnResetAll(self, e):\r
+       def OnResetAll(self, e = None):\r
                profile.putProfileSetting('model_scale', '1.0')\r
                profile.putProfileSetting('model_rotate_base', '0')\r
                profile.putProfileSetting('flip_x', 'False')\r
@@ -312,8 +320,11 @@ class previewPanel(wx.Panel):
                profile.putProfileSetting('swap_xz', 'False')\r
                profile.putProfileSetting('swap_yz', 'False')\r
                self.updateProfileToControls()\r
+       \r
+       def OnWarningPopup(self, e):\r
                self.warningPopup.Show(False)\r
                self.warningPopup.timer.Stop()\r
+               self.warningPopup.callback()\r
 \r
        def OnHideWarning(self, e):\r
                self.warningPopup.Show(False)\r
@@ -676,7 +687,7 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
                                glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE)\r
                        elif self.viewMode == "Normal":\r
                                glLightfv(GL_LIGHT0, GL_DIFFUSE, self.objColor[self.parent.objectList.index(obj)])\r
-                               glLightfv(GL_LIGHT0, GL_AMBIENT, map(lambda x: x / 5, self.objColor[self.parent.objectList.index(obj)]))\r
+                               glLightfv(GL_LIGHT0, GL_AMBIENT, map(lambda x: x * 0.4, self.objColor[self.parent.objectList.index(obj)]))\r
                                glEnable(GL_LIGHTING)\r
                                self.drawModel(obj)\r
 \r
index 0cbdc2d3810ddd72a9c0d5dcf59e8096d2b4b68a..1500a59d42e7394f74e32f652dc606064b3a6ab2 100644 (file)
@@ -4,6 +4,7 @@ import __init__
 import wx, sys, os, shutil, math, threading, subprocess, time, re
 
 from gui import taskbar
+from gui import preferencesDialog
 from util import profile
 from util import sliceRun
 from util import exporer
@@ -72,6 +73,14 @@ class sliceProgessPanel(wx.Panel):
                exporer.openExporer(sliceRun.getExportFilename(self.filelist[0]))
        
        def OnCopyToSD(self, e):
+               if profile.getPreference('sdpath') == '':
+                       wx.MessageBox("You need to configure your SD card drive first before you can copy files to it.\nOpening the preferences now.", 'No SD card drive.', wx.OK | wx.ICON_INFORMATION)
+                       prefDialog = preferencesDialog.preferencesDialog(self.GetParent())
+                       prefDialog.Centre()
+                       prefDialog.Show(True)
+                       if profile.getPreference('sdpath') == '':
+                               print "No path set"
+                               return
                exportFilename = sliceRun.getExportFilename(self.filelist[0])
                filename = os.path.basename(exportFilename)
                if profile.getPreference('sdshortnames') == 'True':
@@ -98,8 +107,8 @@ class sliceProgessPanel(wx.Panel):
                                self.openFileLocationButton = wx.Button(self, -1, "Open file location")
                                self.Bind(wx.EVT_BUTTON, self.OnOpenFileLocation, self.openFileLocationButton)
                                self.sizer.Add(self.openFileLocationButton, 0)
-                       if profile.getPreference('sdpath') != '':
-                               self.copyToSDButton = wx.Button(self, -1, "To SDCard")
+                       if len(profile.getSDcardDrives()) > 0:
+                               self.copyToSDButton = wx.Button(self, -1, "Copy to SDCard")
                                self.Bind(wx.EVT_BUTTON, self.OnCopyToSD, self.copyToSDButton)
                                self.sizer.Add(self.copyToSDButton, 0)
                        self.showButton = wx.Button(self, -1, "Show result")
index 631168573a1970998835ba3e74fa516851a0f05c..62d2af96d6bc8e6d15833e3d45777d17906c7ad7 100644 (file)
Binary files a/Cura/images/ultimaker_platform.stl and b/Cura/images/ultimaker_platform.stl differ
index e029be26781ffd241ded2b94ef8e6b17aa801e37..8d6978bf10d53d63ffde35932b3e60d6e658bc59 100644 (file)
@@ -56,6 +56,7 @@ class gcode(object):
                totalExtrusion = 0.0
                maxExtrusion = 0.0
                currentExtruder = 0
+               extrudeAmountMultiply = 1.0
                totalMoveTimeMinute = 0.0
                scale = 1.0
                posAbs = True
@@ -66,6 +67,7 @@ class gcode(object):
                currentLayer = []
                currentPath = gcodePath('move', pathType, layerThickness, pos.copy())
                currentPath.list[0].e = totalExtrusion
+               currentPath.list[0].extrudeAmountMultiply = extrudeAmountMultiply
                currentLayer.append(currentPath)
                for line in gcodeFile:
                        if type(line) is tuple:
@@ -141,15 +143,13 @@ class gcode(object):
                                                                moveType = 'extrude'
                                                        if e < currentE:
                                                                moveType = 'retract'
-                                                       totalExtrusion += e - currentE
-                                                       currentE = e
                                                else:
                                                        if e > 0:
                                                                moveType = 'extrude'
                                                        if e < 0:
                                                                moveType = 'retract'
-                                                       totalExtrusion += e
-                                                       currentE += e
+                                               totalExtrusion += e - currentE
+                                               currentE = e
                                                if totalExtrusion > maxExtrusion:
                                                        maxExtrusion = totalExtrusion
                                        if moveType == 'move' and oldPos.z != pos.z:
@@ -161,6 +161,7 @@ class gcode(object):
                                                currentLayer.append(currentPath)
                                        newPos = pos.copy()
                                        newPos.e = totalExtrusion
+                                       newPos.extrudeAmountMultiply = extrudeAmountMultiply
                                        currentPath.list.append(newPos)
                                elif G == 4:    #Delay
                                        S = self.getCodeFloat(line, 'S')
@@ -242,6 +243,10 @@ class gcode(object):
                                                pass
                                        elif M == 190:  #Set bed temperature & wait
                                                pass
+                                       elif M == 221:  #Extrude amount multiplier
+                                               s = self.getCodeFloat(line, 'S')
+                                               if s != None:
+                                                       extrudeAmountMultiply = s / 100.0
                                        else:
                                                print "Unknown M code:" + str(M)
                self.layerList.append(currentLayer)
index b59cd8e5d4b1db84aaf2d5570a02643fac7e9f3b..bbc2982b72c5a27d15d61d68b3995c42715da9b7 100644 (file)
@@ -3,7 +3,7 @@ from __future__ import division
 #Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.\r
 import __init__\r
 \r
-import os, traceback, math, re, zlib, base64, time, sys, platform, glob\r
+import os, traceback, math, re, zlib, base64, time, sys, platform, glob, string\r
 import cPickle as pickle\r
 if sys.version_info[0] < 3:\r
        import ConfigParser\r
@@ -621,3 +621,20 @@ def runPostProcessingPlugins(gcodefilename):
                        locationInfo = traceback.extract_tb(sys.exc_info()[2])[-1]\r
                        return "%s: '%s' @ %s:%s:%d" % (str(sys.exc_info()[0].__name__), str(sys.exc_info()[1]), os.path.basename(locationInfo[0]), locationInfo[2], locationInfo[1])\r
        return None\r
+\r
+def getSDcardDrives():\r
+       drives = ['']\r
+       if platform.system() == "Windows":\r
+               from ctypes import windll\r
+               bitmask = windll.kernel32.GetLogicalDrives()\r
+               for letter in string.uppercase:\r
+                       if bitmask & 1:\r
+                               drives.append(letter + ':/')\r
+                       bitmask >>= 1\r
+       if platform.system() == "Darwin":\r
+               drives = []\r
+               for volume in glob.glob('/Volumes/*'):\r
+                       if stat.S_ISLNK(os.lstat(volume).st_mode):\r
+                               continue\r
+                       drives.append(volume)\r
+       return drives\r