From: daid303 Date: Thu, 14 Feb 2013 17:12:57 +0000 (+0100) Subject: Add the option to cut the bottom of a model, for none-flat bottoms. X-Git-Tag: 13.03~46 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=2509f6662eaa7477d11d44dc385f2029007baf98;p=cura.git Add the option to cut the bottom of a model, for none-flat bottoms. --- diff --git a/Cura/gui/configBase.py b/Cura/gui/configBase.py index dd3c3f40..43c5a784 100644 --- a/Cura/gui/configBase.py +++ b/Cura/gui/configBase.py @@ -3,6 +3,7 @@ from __future__ import division import platform import wx, wx.lib.stattext, types +from wx.lib.agw import floatspin from Cura.util import validators from Cura.util import profile @@ -163,6 +164,13 @@ class SettingRow(): self.ctrl = wx.TextCtrl(panel, -1, getSettingFunc(configName)) self.ctrl.Bind(wx.EVT_TEXT, self.OnSettingChange) flag = wx.EXPAND + elif isinstance(defaultValue, types.FloatType): + digits = 0 + while 1 / pow(10, digits) > defaultValue: + digits += 1 + self.ctrl = floatspin.FloatSpin(panel, -1, value=float(getSettingFunc(configName)), increment=defaultValue, digits=digits, min_val=0.0) + self.ctrl.Bind(floatspin.EVT_FLOATSPIN, self.OnSettingChange) + flag = wx.EXPAND elif isinstance(defaultValue, types.BooleanType): self.ctrl = wx.CheckBox(panel, -1, style=wx.ALIGN_RIGHT) self.SetValue(getSettingFunc(configName)) @@ -193,8 +201,12 @@ class SettingRow(): self.ctrl.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) self.ctrl.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseExit) - - self.defaultBGColour = self.ctrl.GetBackgroundColour() + if isinstance(self.ctrl, floatspin.FloatSpin): + self.ctrl.GetTextCtrl().Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) + self.ctrl.GetTextCtrl().Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseExit) + self.defaultBGColour = self.ctrl.GetTextCtrl().GetBackgroundColour() + else: + self.defaultBGColour = self.ctrl.GetBackgroundColour() panel.main.settingControlList.append(self) @@ -220,13 +232,16 @@ class SettingRow(): result = res if res != validators.SUCCESS: msgs.append(err) + ctrl = self.ctrl + if isinstance(ctrl, floatspin.FloatSpin): + ctrl = ctrl.GetTextCtrl() if result == validators.ERROR: - self.ctrl.SetBackgroundColour('Red') + ctrl.SetBackgroundColour('Red') elif result == validators.WARNING: - self.ctrl.SetBackgroundColour('Yellow') + ctrl.SetBackgroundColour('Yellow') else: - self.ctrl.SetBackgroundColour(self.defaultBGColour) - self.ctrl.Refresh() + ctrl.SetBackgroundColour(self.defaultBGColour) + ctrl.Refresh() self.validationMsg = '\n'.join(msgs) self.panel.main.UpdatePopup(self) @@ -242,6 +257,11 @@ class SettingRow(): self.ctrl.SetValue(str(value) == "True") elif isinstance(self.ctrl, wx.ColourPickerCtrl): self.ctrl.SetColour(value) + elif isinstance(self.ctrl, floatspin.FloatSpin): + try: + self.ctrl.SetValue(float(value)) + except ValueError: + pass else: self.ctrl.SetValue(value) diff --git a/Cura/gui/mainWindow.py b/Cura/gui/mainWindow.py index 47aaef71..d58188f6 100644 --- a/Cura/gui/mainWindow.py +++ b/Cura/gui/mainWindow.py @@ -109,12 +109,12 @@ class mainWindow(wx.Frame): self.switchToNormalMenuItem = i self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i) toolsMenu.AppendSeparator() - i = toolsMenu.Append(-1, 'Batch run...') - self.Bind(wx.EVT_MENU, self.OnBatchRun, i) - self.normalModeOnlyItems.append(i) i = toolsMenu.Append(-1, 'Project planner...') self.Bind(wx.EVT_MENU, self.OnProjectPlanner, i) self.normalModeOnlyItems.append(i) + i = toolsMenu.Append(-1, 'Batch run...') + self.Bind(wx.EVT_MENU, self.OnBatchRun, i) + self.normalModeOnlyItems.append(i) # i = toolsMenu.Append(-1, 'Open SVG (2D) slicer...') # self.Bind(wx.EVT_MENU, self.OnSVGSlicerOpen, i) if minecraftImport.hasMinecraft(): @@ -621,6 +621,9 @@ class normalSettingsPanel(configBase.configPanelBase): c = configBase.SettingRow(right, "Initial layer thickness (mm)", 'bottom_thickness', '0.0', 'Layer thickness of the bottom layer. A thicker bottom layer makes sticking to the bed easier. Set to 0.0 to have the bottom layer thickness the same as the other layers.') validators.validFloat(c, 0.0) 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, "Cut off object bottom (mm)", 'object_sink', 0.05, '...') + validators.validFloat(c, 0.0) + configBase.settingNotify(c, lambda : self.GetParent().GetParent().GetParent().preview3d.Refresh()) c = configBase.SettingRow(right, "Duplicate outlines", '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.') self.SizeLabelWidths(left, right) diff --git a/Cura/gui/preview3d.py b/Cura/gui/preview3d.py index bbca2721..9c63fa7e 100644 --- a/Cura/gui/preview3d.py +++ b/Cura/gui/preview3d.py @@ -687,7 +687,7 @@ class PreviewGLCanvas(openglGui.glGuiPanel): wx.CallAfter(self.Refresh) glPushMatrix() - glTranslate(self.parent.machineCenter.x, self.parent.machineCenter.y, 0) + glTranslate(self.parent.machineCenter.x, self.parent.machineCenter.y, -profile.getProfileSettingFloat('object_sink')) for obj in self.parent.objectList: if obj.mesh is None: continue @@ -743,7 +743,7 @@ class PreviewGLCanvas(openglGui.glGuiPanel): glColor3f(1.0,1.0,1.0) glPushMatrix() - glTranslate(self.parent.machineCenter.x, self.parent.machineCenter.y, 0) + glTranslate(self.parent.machineCenter.x, self.parent.machineCenter.y, -profile.getProfileSettingFloat('object_sink')) for obj in self.parent.objectList: if obj.mesh is None: continue diff --git a/Cura/slice/cura_sf/fabmetheus_utilities/settings.py b/Cura/slice/cura_sf/fabmetheus_utilities/settings.py index 9315c126..b7dfdd94 100644 --- a/Cura/slice/cura_sf/fabmetheus_utilities/settings.py +++ b/Cura/slice/cura_sf/fabmetheus_utilities/settings.py @@ -109,6 +109,7 @@ def getProfileInformation(): 'ObjectMatrix': storedSetting("object_matrix"), 'CenterX': lambda setting: profile.getProfileSettingFloat('object_center_x'), 'CenterY': lambda setting: profile.getProfileSettingFloat('object_center_y'), + 'ObjectSink': storedSetting("object_sink"), 'AlternativeCenterFile': storedSetting("alternative_center"), },'scale': { 'Activate_Scale': "False", diff --git a/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/carve.py b/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/carve.py index 3b36e2c4..feeaee4b 100644 --- a/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/carve.py +++ b/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/carve.py @@ -172,6 +172,7 @@ class CarveRepository(object): self.centerX = settings.FloatSpin().getFromValue(0.0, 'CenterX', self, 1000.0, 0.0); self.centerY = settings.FloatSpin().getFromValue(0.0, 'CenterY', self, 1000.0, 0.0); + self.objectSink = settings.FloatSpin().getFromValue(0.0, 'ObjectSink', self, 1000.0, 0.0) self.matrix = settings.StringSetting().getFromValue('ObjectMatrix', self, '1,0,0,0,1,0,0,0,1') self.alternativeCenter = settings.StringSetting().getFromValue('AlternativeCenterFile', self, '') @@ -217,7 +218,7 @@ class CarveSkein(object): minSize = carving.getCarveCornerMinimum() maxSize = carving.getCarveCornerMaximum() for v in carving.vertexes: - v.z -= minZ + v.z -= minZ + repository.objectSink.value v.x -= minSize.x + (maxSize.x - minSize.x) / 2 v.y -= minSize.y + (maxSize.y - minSize.y) / 2 v.x += repository.centerX.value diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 3575f31c..ff9988bd 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -67,6 +67,7 @@ profileDefaultSettings = { 'plugin_config': '', 'object_center_x': '-1', 'object_center_y': '-1', + 'object_sink': '0.0', 'gcode_extension': 'gcode', 'alternative_center': '',