chiark / gitweb /
Add the option to cut the bottom of a model, for none-flat bottoms.
authordaid303 <daid303@gmail.com>
Thu, 14 Feb 2013 17:12:57 +0000 (18:12 +0100)
committerdaid303 <daid303@gmail.com>
Thu, 14 Feb 2013 17:12:57 +0000 (18:12 +0100)
Cura/gui/configBase.py
Cura/gui/mainWindow.py
Cura/gui/preview3d.py
Cura/slice/cura_sf/fabmetheus_utilities/settings.py
Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/carve.py
Cura/util/profile.py

index dd3c3f40f08f09b43c97c3de897078c23a1871a9..43c5a784621d7db6f49540358b98a558595a8f1b 100644 (file)
@@ -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)
 
index 47aaef714dec10333419c559f5751723e43cdf0d..d58188f6c9a97956fc40f2537abe125f9322dd13 100644 (file)
@@ -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)
index bbca27215859b02e500bcaeb57aeb7afc1d88038..9c63fa7e38a2746dee424ce21922010d61da7a76 100644 (file)
@@ -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
index 9315c1260f4dac5051c0fe05f918d1e16d757a07..b7dfdd949a7fd3c26eda1e698b9de0bdc6d9c081 100644 (file)
@@ -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",
index 3b36e2c40b884d9a8c5a6d5233e1f06a0359b8cb..feeaee4bea0b0d867763102ccc9998cbaf288e0b 100644 (file)
@@ -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
index 3575f31c6be40a50e7c2d7103c72c2fe63f91ef2..ff9988bd61ff507d440c31b8c84276b6bdbd9c85 100644 (file)
@@ -67,6 +67,7 @@ profileDefaultSettings = {
        'plugin_config': '',
        'object_center_x': '-1',
        'object_center_y': '-1',
+       'object_sink': '0.0',
        
        'gcode_extension': 'gcode',
        'alternative_center': '',