chiark / gitweb /
Added general help for plugin tab, added open plugin folder button, fixed scale to...
authordaid303 <daid303@gmail.com>
Tue, 27 Nov 2012 12:15:32 +0000 (13:15 +0100)
committerdaid303 <daid303@gmail.com>
Tue, 27 Nov 2012 12:15:32 +0000 (13:15 +0100)
Cura/avr_isp/stk500v2.py
Cura/gui/opengl.py
Cura/gui/pluginPanel.py
Cura/gui/preview3d.py
Cura/gui/printWindow.py
Cura/util/exporer.py
Cura/util/profile.py

index a66b341db2212d80ad1787285d4468bd64b033f7..8577d86d8088bc9a0039bdfe8ae11853af40b1e3 100644 (file)
@@ -12,7 +12,7 @@ class Stk500v2(ispBase.IspBase):
                self.lastAddr = -1\r
                self.progressCallback = None\r
        \r
-       def connect(self, port = 'COM17', speed = 115200):\r
+       def connect(self, port = 'COM22', speed = 115200):\r
                if self.serial != None:\r
                        self.close()\r
                try:\r
@@ -146,8 +146,8 @@ class Stk500v2(ispBase.IspBase):
 \r
 def main():\r
        programmer = Stk500v2()\r
-       programmer.connect()\r
-       programmer.programChip(intelHex.readHex(sys.argv[1]))\r
+       programmer.connect(port = sys.argv[1])\r
+       programmer.programChip(intelHex.readHex(sys.argv[2]))\r
        sys.exit(1)\r
 \r
 if __name__ == '__main__':\r
index 8a61d16e0ebbde3abfe2e2b68bfbaeda3bb10ff0..9a8db81d26600f8c7fcc3a585654e96a16297a68 100644 (file)
@@ -346,6 +346,43 @@ def DrawMesh(mesh):
        glDisableClientState(GL_VERTEX_ARRAY)\r
        glDisableClientState(GL_NORMAL_ARRAY);\r
 \r
+def DrawMeshSteep(mesh, angle):\r
+       cosAngle = math.sin(angle / 180.0 * math.pi)\r
+       glDisable(GL_LIGHTING)\r
+       glDepthFunc(GL_EQUAL)\r
+       for i in xrange(0, int(mesh.vertexCount), 3):\r
+               if mesh.normal[i][2] < -0.999999:\r
+                       if mesh.vertexes[i+0][2] > 0.01:\r
+                               glColor3f(0.5,0,0)\r
+                               glBegin(GL_TRIANGLES)\r
+                               glVertex3f(mesh.vertexes[i+0][0], mesh.vertexes[i+0][1], mesh.vertexes[i+0][2])\r
+                               glVertex3f(mesh.vertexes[i+1][0], mesh.vertexes[i+1][1], mesh.vertexes[i+1][2])\r
+                               glVertex3f(mesh.vertexes[i+2][0], mesh.vertexes[i+2][1], mesh.vertexes[i+2][2])\r
+                               glEnd()\r
+               elif mesh.normal[i][2] < -cosAngle:\r
+                       glColor3f(-mesh.normal[i][2],0,0)\r
+                       glBegin(GL_TRIANGLES)\r
+                       glVertex3f(mesh.vertexes[i+0][0], mesh.vertexes[i+0][1], mesh.vertexes[i+0][2])\r
+                       glVertex3f(mesh.vertexes[i+1][0], mesh.vertexes[i+1][1], mesh.vertexes[i+1][2])\r
+                       glVertex3f(mesh.vertexes[i+2][0], mesh.vertexes[i+2][1], mesh.vertexes[i+2][2])\r
+                       glEnd()\r
+               elif mesh.normal[i][2] > 0.999999:\r
+                       if mesh.vertexes[i+0][2] > 0.01:\r
+                               glColor3f(0.5,0,0)\r
+                               glBegin(GL_TRIANGLES)\r
+                               glVertex3f(mesh.vertexes[i+0][0], mesh.vertexes[i+0][1], mesh.vertexes[i+0][2])\r
+                               glVertex3f(mesh.vertexes[i+2][0], mesh.vertexes[i+2][1], mesh.vertexes[i+2][2])\r
+                               glVertex3f(mesh.vertexes[i+1][0], mesh.vertexes[i+1][1], mesh.vertexes[i+1][2])\r
+                               glEnd()\r
+               elif mesh.normal[i][2] > cosAngle:\r
+                       glColor3f(mesh.normal[i][2],0,0)\r
+                       glBegin(GL_TRIANGLES)\r
+                       glVertex3f(mesh.vertexes[i+0][0], mesh.vertexes[i+0][1], mesh.vertexes[i+0][2])\r
+                       glVertex3f(mesh.vertexes[i+2][0], mesh.vertexes[i+2][1], mesh.vertexes[i+2][2])\r
+                       glVertex3f(mesh.vertexes[i+1][0], mesh.vertexes[i+1][1], mesh.vertexes[i+1][2])\r
+                       glEnd()\r
+       glDepthFunc(GL_LESS)\r
+\r
 def DrawGCodeLayer(layer):\r
        filamentRadius = profile.getProfileSettingFloat('filament_diameter') / 2\r
        filamentArea = math.pi * filamentRadius * filamentRadius\r
index 8ae787f90cfbd5d825d57d6ce3c9972f7cc128be..204693afe02c975c01635af1d2711daef06f572a 100644 (file)
@@ -3,6 +3,7 @@ import sys, math, threading, os, webbrowser
 from wx.lib import scrolledpanel
 
 from util import profile
+from util import exporer
 
 class pluginPanel(wx.Panel):
        def __init__(self, parent):
@@ -20,19 +21,23 @@ class pluginPanel(wx.Panel):
                self.listbox = wx.ListBox(self, -1, choices=effectStringList)
                title = wx.StaticText(self, -1, "Plugins:")
                title.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD))
+               helpButton = wx.Button(self, -1, '?', style=wx.BU_EXACTFIT)
                addButton = wx.Button(self, -1, '>', style=wx.BU_EXACTFIT)
+               openPluginLocationButton = wx.Button(self, -1, 'Open plugin location')
                sb = wx.StaticBox(self, label="Enabled plugins")
                boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
                self.pluginEnabledPanel = scrolledpanel.ScrolledPanel(self)
                self.pluginEnabledPanel.SetupScrolling(False, True)
                
                sizer.Add(title, (0,0), border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.TOP)
-               sizer.Add(self.listbox, (1,0), span=(2,1), border=10, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM)
-               sizer.Add(addButton, (1,1), border=5, flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_BOTTOM)
-               sizer.Add(boxsizer, (1,2), span=(2,1), border=10, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM)
+               sizer.Add(helpButton, (0,1), border=10, flag=wx.ALIGN_RIGHT|wx.RIGHT|wx.TOP)
+               sizer.Add(self.listbox, (1,0), span=(2,2), border=10, flag=wx.EXPAND|wx.LEFT|wx.RIGHT)
+               sizer.Add(addButton, (1,2), border=5, flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_BOTTOM)
+               sizer.Add(boxsizer, (1,3), span=(2,1), border=10, flag=wx.EXPAND|wx.LEFT|wx.RIGHT)
+               sizer.Add(openPluginLocationButton, (3, 0), span=(1,2), border=10, flag=wx.LEFT|wx.BOTTOM)
                boxsizer.Add(self.pluginEnabledPanel, 1, flag=wx.EXPAND)
                
-               sizer.AddGrowableCol(2)
+               sizer.AddGrowableCol(3)
                sizer.AddGrowableRow(1)
                sizer.AddGrowableRow(2)
                
@@ -40,6 +45,8 @@ class pluginPanel(wx.Panel):
                self.pluginEnabledPanel.SetSizer(sizer)
                
                self.Bind(wx.EVT_BUTTON, self.OnAdd, addButton)
+               self.Bind(wx.EVT_BUTTON, self.OnGeneralHelp, helpButton)
+               self.Bind(wx.EVT_BUTTON, self.OnOpenPluginLocation, openPluginLocationButton)
                self.listbox.Bind(wx.EVT_LEFT_DCLICK, self.OnAdd)
                self.panelList = []
                self.updateProfileToControls()
@@ -152,3 +159,9 @@ class pluginPanel(wx.Panel):
                fname = fname[0].upper() + fname[1:]
                fname = fname[:fname.rfind('.')]
                webbrowser.open('http://wiki.ultimaker.com/CuraPlugin:_' + fname)
+       
+       def OnGeneralHelp(self, e):
+               webbrowser.open('http://wiki.ultimaker.com/Category:CuraPlugin')
+       
+       def OnOpenPluginLocation(self, e):
+               exporer.openExporerPath(profile.getPluginBasePaths()[0])
index fb9df6433caba453275163258a01f9e5b9c618a6..58f269f22ee0e9afbc2de4d596f22d2a1ad1b762 100644 (file)
@@ -77,6 +77,7 @@ class previewPanel(wx.Panel):
                self.toolbar.AddSeparator()\r
 \r
                self.showBorderButton = toolbarUtil.ToggleButton(self.toolbar, '', 'view-border-on.png', 'view-border-off.png', 'Show model borders', callback=self.OnViewChange)\r
+               self.showSteepOverhang = toolbarUtil.ToggleButton(self.toolbar, '', 'view-border-on.png', 'view-border-off.png', 'Show steep overhang', callback=self.OnViewChange)\r
                self.toolbar.AddSeparator()\r
 \r
                group = []\r
@@ -170,17 +171,22 @@ class previewPanel(wx.Panel):
                profile.putProfileSetting('model_scale', scale)\r
                self.glCanvas.Refresh()\r
        \r
-       def OnScaleMax(self, e):\r
+       def OnScaleMax(self, e = None, onlyScaleDown = False):\r
                if self.objectsMinV == None:\r
                        return\r
                vMin = self.objectsMinV\r
                vMax = self.objectsMaxV\r
-               scaleX1 = (self.machineSize.x - self.machineCenter.x) / ((vMax[0] - vMin[0]) / 2)\r
-               scaleY1 = (self.machineSize.y - self.machineCenter.y) / ((vMax[1] - vMin[1]) / 2)\r
-               scaleX2 = (self.machineCenter.x) / ((vMax[0] - vMin[0]) / 2)\r
-               scaleY2 = (self.machineCenter.y) / ((vMax[1] - vMin[1]) / 2)\r
+               skirtSize = 3\r
+               if profile.getProfileSettingFloat('skirt_line_count') > 0:\r
+                       skirtSize = 3 + profile.getProfileSettingFloat('skirt_line_count') * profile.calculateEdgeWidth() + profile.getProfileSettingFloat('skirt_gap')\r
+               scaleX1 = (self.machineSize.x - self.machineCenter.x - skirtSize) / ((vMax[0] - vMin[0]) / 2)\r
+               scaleY1 = (self.machineSize.y - self.machineCenter.y - skirtSize) / ((vMax[1] - vMin[1]) / 2)\r
+               scaleX2 = (self.machineCenter.x - skirtSize) / ((vMax[0] - vMin[0]) / 2)\r
+               scaleY2 = (self.machineCenter.y - skirtSize) / ((vMax[1] - vMin[1]) / 2)\r
                scaleZ = self.machineSize.z / (vMax[2] - vMin[2])\r
                scale = min(scaleX1, scaleY1, scaleX2, scaleY2, scaleZ)\r
+               if scale > 1.0 and onlyScaleDown:\r
+                       return\r
                self.scale.SetValue(str(scale))\r
                profile.putProfileSetting('model_scale', self.scale.GetValue())\r
                self.glCanvas.Refresh()\r
@@ -249,8 +255,8 @@ class previewPanel(wx.Panel):
                self.loadThread.start()\r
                \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.ShowWarningPopup('Reset scale, rotation and mirror?', self.OnResetAll)\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' or len(profile.getPluginConfig()) > 0:\r
+                               self.ShowWarningPopup('Reset scale, rotation, mirror and plugins?', self.OnResetAll)\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
@@ -270,8 +276,7 @@ class previewPanel(wx.Panel):
                                self.updateModelTransform()\r
                                scale = profile.getProfileSettingFloat('model_scale')\r
                                size = (self.objectsMaxV - self.objectsMinV) * scale\r
-                               if size[0] > self.machineSize.x or size[1] > self.machineSize.y or size[2] > self.machineSize.z:\r
-                                       self.OnScaleMax(None)\r
+                               self.OnScaleMax(None, True)\r
                                self.glCanvas.zoom = numpy.max(size) * 2.5\r
                                self.errorList = []\r
                                wx.CallAfter(self.updateToolbar)\r
@@ -311,7 +316,8 @@ class previewPanel(wx.Panel):
                profile.putProfileSetting('flip_z', 'False')\r
                profile.putProfileSetting('swap_xz', 'False')\r
                profile.putProfileSetting('swap_yz', 'False')\r
-               self.updateProfileToControls()\r
+               profile.setPluginConfig([])\r
+               self.GetParent().updateProfileToControls()\r
 \r
        def ShowWarningPopup(self, text, callback = None):\r
                self.warningPopup.text.SetLabel(text)\r
@@ -358,6 +364,7 @@ class previewPanel(wx.Panel):
                elif self.mixedViewButton.GetValue():\r
                        self.glCanvas.viewMode = "Mixed"\r
                self.glCanvas.drawBorders = self.showBorderButton.GetValue()\r
+               self.glCanvas.drawSteepOverhang = self.showSteepOverhang.GetValue()\r
                self.updateToolbar()\r
                self.glCanvas.Refresh()\r
        \r
@@ -580,12 +587,16 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
                        if obj.mesh == None:\r
                                continue\r
                        if obj.displayList == None:\r
-                               obj.displayList = glGenLists(1);\r
+                               obj.displayList = glGenLists(1)\r
+                               obj.steepDisplayList = glGenLists(1)\r
                        if obj.dirty:\r
                                obj.dirty = False\r
                                glNewList(obj.displayList, GL_COMPILE)\r
                                opengl.DrawMesh(obj.mesh)\r
                                glEndList()\r
+                               glNewList(obj.steepDisplayList, GL_COMPILE)\r
+                               opengl.DrawMeshSteep(obj.mesh, 60)\r
+                               glEndList()\r
                        \r
                        if self.viewMode == "Mixed":\r
                                glDisable(GL_BLEND)\r
@@ -706,6 +717,15 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
                                glScalef(modelScale, modelScale, modelScale)\r
                                opengl.DrawMeshOutline(obj.mesh)\r
                                glPopMatrix()\r
+                       \r
+                       if self.drawSteepOverhang:\r
+                               glDisable(GL_LIGHTING)\r
+                               glColor3f(1,1,1)\r
+                               glPushMatrix()\r
+                               modelScale = profile.getProfileSettingFloat('model_scale')\r
+                               glScalef(modelScale, modelScale, modelScale)\r
+                               glCallList(obj.steepDisplayList)\r
+                               glPopMatrix()\r
                \r
                glPopMatrix()   \r
                if self.viewMode == "Normal" or self.viewMode == "Transparent" or self.viewMode == "X-Ray":\r
index 0b8e2a4ee54960007cbb1eff5cdd8fa287d2f3d9..49cdd54504068770396d562314075e8d7ca9386f 100644 (file)
@@ -495,9 +495,11 @@ class printWindow(wx.Frame):
                type = self.powerManagement.get_providing_power_source_type()\r
                if type == power.POWER_TYPE_AC and self.powerWarningText.IsShown():\r
                        self.powerWarningText.Hide()\r
+                       self.panel.Layout()\r
                        self.Layout()\r
                elif type != power.POWER_TYPE_AC and not self.powerWarningText.IsShown():\r
                        self.powerWarningText.Show()\r
+                       self.panel.Layout()\r
                        self.Layout()\r
 \r
        def LoadGCodeFile(self, filename):\r
index 109711b48a8ed9243e00528349e49470b6a1db2a..7ca6d3e497f25a38cd867dd33f009995c671ec3e 100644 (file)
@@ -21,3 +21,14 @@ def openExporer(filename):
                elif os.path.isfile('/usr/bin/dolphin'):
                        subprocess.Popen(['/usr/bin/dolphin', os.path.split(filename)[0]])
 
+def openExporerPath(filename):
+       if sys.platform == 'win32' or sys.platform == 'cygwin':
+               subprocess.Popen(r'explorer "%s"' % (filename))
+       if sys.platform == 'darwin':
+               subprocess.Popen(['open', filename])
+       if sys.platform.startswith('linux'):
+               if os.path.isfile('/usr/bin/nautilus'):
+                       subprocess.Popen(['/usr/bin/nautilus', filename])
+               elif os.path.isfile('/usr/bin/dolphin'):
+                       subprocess.Popen(['/usr/bin/dolphin', filename])
+
index 12469ba87208adb08f685897c74b7cead8b78623..e48c53d0cad82acf12aae138e2d0469b2831e8d2 100644 (file)
@@ -545,9 +545,10 @@ def setPluginConfig(config):
        putProfileSetting('plugin_config', pickle.dumps(config))\r
 \r
 def getPluginBasePaths():\r
-       ret = [os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'plugins'))]\r
+       ret = []\r
        if platform.system() != "Windows":\r
                ret.append(os.path.expanduser('~/.cura/plugins/'))\r
+       ret.append(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'plugins')))\r
        return ret\r
 \r
 def getPluginList():\r