From 558e9d478adf64b4cbc7456f19c27d45375aee20 Mon Sep 17 00:00:00 2001 From: daid303 Date: Tue, 27 Nov 2012 13:15:32 +0100 Subject: [PATCH] Added general help for plugin tab, added open plugin folder button, fixed scale to max size to account for skirt, added steep overhang view (still needs icons). --- Cura/avr_isp/stk500v2.py | 6 +++--- Cura/gui/opengl.py | 37 +++++++++++++++++++++++++++++++++++ Cura/gui/pluginPanel.py | 21 ++++++++++++++++---- Cura/gui/preview3d.py | 42 +++++++++++++++++++++++++++++----------- Cura/gui/printWindow.py | 2 ++ Cura/util/exporer.py | 11 +++++++++++ Cura/util/profile.py | 3 ++- 7 files changed, 103 insertions(+), 19 deletions(-) diff --git a/Cura/avr_isp/stk500v2.py b/Cura/avr_isp/stk500v2.py index a66b341d..8577d86d 100644 --- a/Cura/avr_isp/stk500v2.py +++ b/Cura/avr_isp/stk500v2.py @@ -12,7 +12,7 @@ class Stk500v2(ispBase.IspBase): self.lastAddr = -1 self.progressCallback = None - def connect(self, port = 'COM17', speed = 115200): + def connect(self, port = 'COM22', speed = 115200): if self.serial != None: self.close() try: @@ -146,8 +146,8 @@ class Stk500v2(ispBase.IspBase): def main(): programmer = Stk500v2() - programmer.connect() - programmer.programChip(intelHex.readHex(sys.argv[1])) + programmer.connect(port = sys.argv[1]) + programmer.programChip(intelHex.readHex(sys.argv[2])) sys.exit(1) if __name__ == '__main__': diff --git a/Cura/gui/opengl.py b/Cura/gui/opengl.py index 8a61d16e..9a8db81d 100644 --- a/Cura/gui/opengl.py +++ b/Cura/gui/opengl.py @@ -346,6 +346,43 @@ def DrawMesh(mesh): glDisableClientState(GL_VERTEX_ARRAY) glDisableClientState(GL_NORMAL_ARRAY); +def DrawMeshSteep(mesh, angle): + cosAngle = math.sin(angle / 180.0 * math.pi) + glDisable(GL_LIGHTING) + glDepthFunc(GL_EQUAL) + for i in xrange(0, int(mesh.vertexCount), 3): + if mesh.normal[i][2] < -0.999999: + if mesh.vertexes[i+0][2] > 0.01: + glColor3f(0.5,0,0) + glBegin(GL_TRIANGLES) + glVertex3f(mesh.vertexes[i+0][0], mesh.vertexes[i+0][1], mesh.vertexes[i+0][2]) + glVertex3f(mesh.vertexes[i+1][0], mesh.vertexes[i+1][1], mesh.vertexes[i+1][2]) + glVertex3f(mesh.vertexes[i+2][0], mesh.vertexes[i+2][1], mesh.vertexes[i+2][2]) + glEnd() + elif mesh.normal[i][2] < -cosAngle: + glColor3f(-mesh.normal[i][2],0,0) + glBegin(GL_TRIANGLES) + glVertex3f(mesh.vertexes[i+0][0], mesh.vertexes[i+0][1], mesh.vertexes[i+0][2]) + glVertex3f(mesh.vertexes[i+1][0], mesh.vertexes[i+1][1], mesh.vertexes[i+1][2]) + glVertex3f(mesh.vertexes[i+2][0], mesh.vertexes[i+2][1], mesh.vertexes[i+2][2]) + glEnd() + elif mesh.normal[i][2] > 0.999999: + if mesh.vertexes[i+0][2] > 0.01: + glColor3f(0.5,0,0) + glBegin(GL_TRIANGLES) + glVertex3f(mesh.vertexes[i+0][0], mesh.vertexes[i+0][1], mesh.vertexes[i+0][2]) + glVertex3f(mesh.vertexes[i+2][0], mesh.vertexes[i+2][1], mesh.vertexes[i+2][2]) + glVertex3f(mesh.vertexes[i+1][0], mesh.vertexes[i+1][1], mesh.vertexes[i+1][2]) + glEnd() + elif mesh.normal[i][2] > cosAngle: + glColor3f(mesh.normal[i][2],0,0) + glBegin(GL_TRIANGLES) + glVertex3f(mesh.vertexes[i+0][0], mesh.vertexes[i+0][1], mesh.vertexes[i+0][2]) + glVertex3f(mesh.vertexes[i+2][0], mesh.vertexes[i+2][1], mesh.vertexes[i+2][2]) + glVertex3f(mesh.vertexes[i+1][0], mesh.vertexes[i+1][1], mesh.vertexes[i+1][2]) + glEnd() + glDepthFunc(GL_LESS) + def DrawGCodeLayer(layer): filamentRadius = profile.getProfileSettingFloat('filament_diameter') / 2 filamentArea = math.pi * filamentRadius * filamentRadius diff --git a/Cura/gui/pluginPanel.py b/Cura/gui/pluginPanel.py index 8ae787f9..204693af 100644 --- a/Cura/gui/pluginPanel.py +++ b/Cura/gui/pluginPanel.py @@ -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]) diff --git a/Cura/gui/preview3d.py b/Cura/gui/preview3d.py index fb9df643..58f269f2 100644 --- a/Cura/gui/preview3d.py +++ b/Cura/gui/preview3d.py @@ -77,6 +77,7 @@ class previewPanel(wx.Panel): self.toolbar.AddSeparator() self.showBorderButton = toolbarUtil.ToggleButton(self.toolbar, '', 'view-border-on.png', 'view-border-off.png', 'Show model borders', callback=self.OnViewChange) + self.showSteepOverhang = toolbarUtil.ToggleButton(self.toolbar, '', 'view-border-on.png', 'view-border-off.png', 'Show steep overhang', callback=self.OnViewChange) self.toolbar.AddSeparator() group = [] @@ -170,17 +171,22 @@ class previewPanel(wx.Panel): profile.putProfileSetting('model_scale', scale) self.glCanvas.Refresh() - def OnScaleMax(self, e): + def OnScaleMax(self, e = None, onlyScaleDown = False): if self.objectsMinV == None: return vMin = self.objectsMinV vMax = self.objectsMaxV - scaleX1 = (self.machineSize.x - self.machineCenter.x) / ((vMax[0] - vMin[0]) / 2) - scaleY1 = (self.machineSize.y - self.machineCenter.y) / ((vMax[1] - vMin[1]) / 2) - scaleX2 = (self.machineCenter.x) / ((vMax[0] - vMin[0]) / 2) - scaleY2 = (self.machineCenter.y) / ((vMax[1] - vMin[1]) / 2) + skirtSize = 3 + if profile.getProfileSettingFloat('skirt_line_count') > 0: + skirtSize = 3 + profile.getProfileSettingFloat('skirt_line_count') * profile.calculateEdgeWidth() + profile.getProfileSettingFloat('skirt_gap') + scaleX1 = (self.machineSize.x - self.machineCenter.x - skirtSize) / ((vMax[0] - vMin[0]) / 2) + scaleY1 = (self.machineSize.y - self.machineCenter.y - skirtSize) / ((vMax[1] - vMin[1]) / 2) + scaleX2 = (self.machineCenter.x - skirtSize) / ((vMax[0] - vMin[0]) / 2) + scaleY2 = (self.machineCenter.y - skirtSize) / ((vMax[1] - vMin[1]) / 2) scaleZ = self.machineSize.z / (vMax[2] - vMin[2]) scale = min(scaleX1, scaleY1, scaleX2, scaleY2, scaleZ) + if scale > 1.0 and onlyScaleDown: + return self.scale.SetValue(str(scale)) profile.putProfileSetting('model_scale', self.scale.GetValue()) self.glCanvas.Refresh() @@ -249,8 +255,8 @@ class previewPanel(wx.Panel): self.loadThread.start() if showWarning: - 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': - self.ShowWarningPopup('Reset scale, rotation and mirror?', self.OnResetAll) + 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: + self.ShowWarningPopup('Reset scale, rotation, mirror and plugins?', self.OnResetAll) def loadReModelFiles(self, filelist): #Only load this again if the filename matches the file we have already loaded (for auto loading GCode after slicing) @@ -270,8 +276,7 @@ class previewPanel(wx.Panel): self.updateModelTransform() scale = profile.getProfileSettingFloat('model_scale') size = (self.objectsMaxV - self.objectsMinV) * scale - if size[0] > self.machineSize.x or size[1] > self.machineSize.y or size[2] > self.machineSize.z: - self.OnScaleMax(None) + self.OnScaleMax(None, True) self.glCanvas.zoom = numpy.max(size) * 2.5 self.errorList = [] wx.CallAfter(self.updateToolbar) @@ -311,7 +316,8 @@ class previewPanel(wx.Panel): profile.putProfileSetting('flip_z', 'False') profile.putProfileSetting('swap_xz', 'False') profile.putProfileSetting('swap_yz', 'False') - self.updateProfileToControls() + profile.setPluginConfig([]) + self.GetParent().updateProfileToControls() def ShowWarningPopup(self, text, callback = None): self.warningPopup.text.SetLabel(text) @@ -358,6 +364,7 @@ class previewPanel(wx.Panel): elif self.mixedViewButton.GetValue(): self.glCanvas.viewMode = "Mixed" self.glCanvas.drawBorders = self.showBorderButton.GetValue() + self.glCanvas.drawSteepOverhang = self.showSteepOverhang.GetValue() self.updateToolbar() self.glCanvas.Refresh() @@ -580,12 +587,16 @@ class PreviewGLCanvas(glcanvas.GLCanvas): if obj.mesh == None: continue if obj.displayList == None: - obj.displayList = glGenLists(1); + obj.displayList = glGenLists(1) + obj.steepDisplayList = glGenLists(1) if obj.dirty: obj.dirty = False glNewList(obj.displayList, GL_COMPILE) opengl.DrawMesh(obj.mesh) glEndList() + glNewList(obj.steepDisplayList, GL_COMPILE) + opengl.DrawMeshSteep(obj.mesh, 60) + glEndList() if self.viewMode == "Mixed": glDisable(GL_BLEND) @@ -706,6 +717,15 @@ class PreviewGLCanvas(glcanvas.GLCanvas): glScalef(modelScale, modelScale, modelScale) opengl.DrawMeshOutline(obj.mesh) glPopMatrix() + + if self.drawSteepOverhang: + glDisable(GL_LIGHTING) + glColor3f(1,1,1) + glPushMatrix() + modelScale = profile.getProfileSettingFloat('model_scale') + glScalef(modelScale, modelScale, modelScale) + glCallList(obj.steepDisplayList) + glPopMatrix() glPopMatrix() if self.viewMode == "Normal" or self.viewMode == "Transparent" or self.viewMode == "X-Ray": diff --git a/Cura/gui/printWindow.py b/Cura/gui/printWindow.py index 0b8e2a4e..49cdd545 100644 --- a/Cura/gui/printWindow.py +++ b/Cura/gui/printWindow.py @@ -495,9 +495,11 @@ class printWindow(wx.Frame): type = self.powerManagement.get_providing_power_source_type() if type == power.POWER_TYPE_AC and self.powerWarningText.IsShown(): self.powerWarningText.Hide() + self.panel.Layout() self.Layout() elif type != power.POWER_TYPE_AC and not self.powerWarningText.IsShown(): self.powerWarningText.Show() + self.panel.Layout() self.Layout() def LoadGCodeFile(self, filename): diff --git a/Cura/util/exporer.py b/Cura/util/exporer.py index 109711b4..7ca6d3e4 100644 --- a/Cura/util/exporer.py +++ b/Cura/util/exporer.py @@ -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]) + diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 12469ba8..e48c53d0 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -545,9 +545,10 @@ def setPluginConfig(config): putProfileSetting('plugin_config', pickle.dumps(config)) def getPluginBasePaths(): - ret = [os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'plugins'))] + ret = [] if platform.system() != "Windows": ret.append(os.path.expanduser('~/.cura/plugins/')) + ret.append(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'plugins'))) return ret def getPluginList(): -- 2.30.2