chiark / gitweb /
Add support to slice as 1 large object with the project planner. Fixed #98
authorDaid <daid303@gmail.com>
Thu, 21 Jun 2012 15:41:10 +0000 (17:41 +0200)
committerDaid <daid303@gmail.com>
Thu, 21 Jun 2012 15:41:10 +0000 (17:41 +0200)
Cura/gui/expertConfig.py
Cura/gui/projectPlanner.py

index 9ab2f1c32a57845746247357ee694fb48cfb4c70..3e409eed7c678560b1d91d8139f1b8e47d9f96a1 100644 (file)
@@ -68,7 +68,9 @@ class expertConfigWindow(configBase.configWindowBase):
                configBase.TitleRow(right, "Dwindle")
                c = configBase.SettingRow(right, "Enable dwindle", 'enable_dwindle', False, 'Dwindle is used to slow down near the end of a printed line, and reducing the amount of filament printed near the end. This to release the preasure on the printer head.')
                c = configBase.SettingRow(right, "Pent up volume (mm3)", 'dwindle_pent_up_volume', '0.4', 'Amount of plastic inside the nozzle under pressure. This normally comes out as ooze after printing.')
+               validators.validFloat(c, 0.0001)
                c = configBase.SettingRow(right, "Slow down volume (mm3)", 'dwindle_slowdown_volume', '5.0', 'Amount of printing volume that is used to slow down to release the pressure.')
+               validators.validFloat(c, 0.0001)
 
                main.Fit()
                self.Fit()
index 5ab1250c495dedcc5b7972cb0bfb708cc4dbabb3..c7fecfd889a5a57efddfdc17e190b1e0d7ca7678 100644 (file)
@@ -138,6 +138,7 @@ class projectPlanner(wx.Frame):
                \r
                self.list = []\r
                self.selection = None\r
+               self.printMode = 0\r
 \r
                self.machineSize = util3d.Vector3(profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth'), profile.getPreferenceFloat('machine_height'))\r
                self.headSizeMin = util3d.Vector3(profile.getPreferenceFloat('extruder_head_size_min_x'), profile.getPreferenceFloat('extruder_head_size_min_y'),0)\r
@@ -163,6 +164,10 @@ class projectPlanner(wx.Frame):
                toolbarUtil.NormalButton(self.toolbar, self.OnCutMesh, 'cut-mesh.png', 'Cut a plate STL into multiple STL files, and add those files to the project.\nNote: Splitting up plates sometimes takes a few minutes.')\r
                toolbarUtil.NormalButton(self.toolbar, self.OnSaveCombinedSTL, 'save-combination.png', 'Save all the combined STL files into a single STL file as a plate.')\r
                self.toolbar.AddSeparator()\r
+               group = []\r
+               self.printOneAtATime = toolbarUtil.RadioButton(self.toolbar, group, 'view-normal-on.png', 'view-normal-off.png', 'Print one object at a time', callback=self.OnPrintTypeChange)\r
+               self.printAllAtOnce = toolbarUtil.RadioButton(self.toolbar, group, 'all-at-once-on.png', 'all-at-once-off.png', 'Print all the objects at once', callback=self.OnPrintTypeChange)\r
+               self.toolbar.AddSeparator()\r
                toolbarUtil.NormalButton(self.toolbar, self.OnQuit, 'exit.png', 'Close project planner')\r
                \r
                self.toolbar.Realize()\r
@@ -273,18 +278,27 @@ class projectPlanner(wx.Frame):
                self.preview.Refresh()\r
                dlg.Destroy()\r
        \r
+       def OnPrintTypeChange(self):\r
+               self.printMode = 0\r
+               if self.printAllAtOnce.GetValue():\r
+                       self.printMode = 1\r
+               self.preview.Refresh()\r
+       \r
        def OnSaveCombinedSTL(self, e):\r
                dlg=wx.FileDialog(self, "Save as STL", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)\r
                dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL")\r
                if dlg.ShowModal() == wx.ID_OK:\r
-                       output = mesh.mesh()\r
-                       for item in self.list:\r
-                               offset = util3d.Vector3(item.centerX, item.centerY, 0)\r
-                               for f in item.faces:\r
-                                       output.addFace(f.v[0] * item.scale + offset, f.v[1] * item.scale + offset, f.v[2] * item.scale + offset)\r
-                       stl.saveAsSTL(output, dlg.GetPath())\r
+                       self._saveCombinedSTL(dlg.GetPath())\r
                dlg.Destroy()\r
        \r
+       def _saveCombinedSTL(filename):\r
+               output = mesh.mesh()\r
+               for item in self.list:\r
+                       offset = util3d.Vector3(item.centerX, item.centerY, 0)\r
+                       for f in item.faces:\r
+                               output.addFace(f.v[0] * item.scale + offset, f.v[1] * item.scale + offset, f.v[2] * item.scale + offset)\r
+               stl.saveAsSTL(output, filename)\r
+       \r
        def OnSaveProject(self, e):\r
                dlg=wx.FileDialog(self, "Save project file", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)\r
                dlg.SetWildcard("Project files (*.curaproject)|*.curaproject")\r
@@ -485,6 +499,10 @@ class projectPlanner(wx.Frame):
                if profile.getProfileSetting('support') != 'None':\r
                        extraSizeMin = extraSizeMin + util3d.Vector3(3.0, 0, 0)\r
                        extraSizeMax = extraSizeMax + util3d.Vector3(3.0, 0, 0)\r
+               \r
+               if self.printMode == 1:\r
+                       extraSizeMin = util3d.Vector3(6.0, 6.0, 0)\r
+                       extraSizeMax = util3d.Vector3(6.0, 6.0, 0)\r
 \r
                if extraSizeMin.x > extraSizeMax.x:\r
                        posX = self.machineSize.x\r
@@ -529,60 +547,81 @@ class projectPlanner(wx.Frame):
                return (maxX - minX) + (maxY - minY)\r
 \r
        def OnSlice(self, e):\r
+               dlg=wx.FileDialog(self, "Save project gcode file", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)\r
+               dlg.SetWildcard("GCode file (*.gcode)|*.gcode")\r
+               if dlg.ShowModal() != wx.ID_OK:\r
+                       dlg.Destroy()\r
+                       return\r
+               resultFilename = dlg.GetPath()\r
+               dlg.Destroy()\r
+\r
                put = profile.setTempOverride\r
                oldProfile = profile.getGlobalProfileString()\r
-\r
-               put('model_multiply_x', '1')\r
-               put('model_multiply_y', '1')\r
-               put('enable_raft', 'False')\r
+               \r
                put('add_start_end_gcode', 'False')\r
                put('gcode_extension', 'project_tmp')\r
-               \r
-               clearZ = 0\r
-               actionList = []\r
-               for item in self.list:\r
-                       if item.profile != None and os.path.isfile(item.profile):\r
-                               profile.loadGlobalProfile(item.profile)\r
-                       put('machine_center_x', item.centerX - self.extruderOffset[item.extruder].x)\r
-                       put('machine_center_y', item.centerY - self.extruderOffset[item.extruder].y)\r
-                       put('model_scale', item.scale)\r
-                       put('flip_x', item.flipX)\r
-                       put('flip_y', item.flipY)\r
-                       put('flip_z', item.flipZ)\r
-                       put('model_rotate_base', item.rotate)\r
-                       put('swap_xz', item.swapXZ)\r
-                       put('swap_yz', item.swapYZ)\r
+               if self.printMode == 0:\r
+                       put('enable_raft', 'False')\r
+                       \r
+                       clearZ = 0\r
+                       actionList = []\r
+                       for item in self.list:\r
+                               if item.profile != None and os.path.isfile(item.profile):\r
+                                       profile.loadGlobalProfile(item.profile)\r
+                               put('machine_center_x', item.centerX - self.extruderOffset[item.extruder].x)\r
+                               put('machine_center_y', item.centerY - self.extruderOffset[item.extruder].y)\r
+                               put('model_scale', item.scale)\r
+                               put('flip_x', item.flipX)\r
+                               put('flip_y', item.flipY)\r
+                               put('flip_z', item.flipZ)\r
+                               put('model_rotate_base', item.rotate)\r
+                               put('swap_xz', item.swapXZ)\r
+                               put('swap_yz', item.swapYZ)\r
+                               \r
+                               action = Action()\r
+                               action.sliceCmd = sliceRun.getSliceCommand(item.filename)\r
+                               action.centerX = item.centerX\r
+                               action.centerY = item.centerY\r
+                               action.extruder = item.extruder\r
+                               action.filename = item.filename\r
+                               clearZ = max(clearZ, item.getMaximum().z * item.scale + 5.0)\r
+                               action.clearZ = clearZ\r
+                               action.leaveResultForNextSlice = False\r
+                               action.usePreviousSlice = False\r
+                               actionList.append(action)\r
+\r
+                               if self.list.index(item) > 0 and item.isSameExceptForPosition(self.list[self.list.index(item)-1]):\r
+                                       actionList[-2].leaveResultForNextSlice = True\r
+                                       actionList[-1].usePreviousSlice = True\r
+\r
+                               if item.profile != None:\r
+                                       profile.loadGlobalProfileFromString(oldProfile)\r
+                       \r
+               else:\r
+                       self._saveCombinedSTL(resultFilename + "_temp_.stl")\r
+                       put('model_scale', 1.0)\r
+                       put('flip_x', False)\r
+                       put('flip_y', False)\r
+                       put('flip_z', False)\r
+                       put('model_rotate_base', 0)\r
+                       put('swap_xz', False)\r
+                       put('swap_yz', False)\r
+                       actionList = []\r
                        \r
                        action = Action()\r
-                       action.sliceCmd = sliceRun.getSliceCommand(item.filename)\r
-                       action.centerX = item.centerX\r
-                       action.centerY = item.centerY\r
-                       action.extruder = item.extruder\r
-                       action.filename = item.filename\r
-                       clearZ = max(clearZ, item.getMaximum().z * item.scale + 5.0)\r
-                       action.clearZ = clearZ\r
+                       action.sliceCmd = sliceRun.getSliceCommand(resultFilename + "_temp_.stl")\r
+                       action.centerX = profile.getProfileSettingFloat('machine_center_x')\r
+                       action.centerY = profile.getProfileSettingFloat('machine_center_y')\r
+                       action.extruder = 0\r
+                       action.filename = resultFilename + "_temp_.stl"\r
+                       action.clearZ = 0\r
                        action.leaveResultForNextSlice = False\r
                        action.usePreviousSlice = False\r
                        actionList.append(action)\r
-\r
-                       if self.list.index(item) > 0 and item.isSameExceptForPosition(self.list[self.list.index(item)-1]):\r
-                               actionList[-2].leaveResultForNextSlice = True\r
-                               actionList[-1].usePreviousSlice = True\r
-\r
-                       if item.profile != None:\r
-                               profile.loadGlobalProfileFromString(oldProfile)\r
-               \r
+                       \r
                #Restore the old profile.\r
                profile.resetTempOverride()\r
                \r
-               dlg=wx.FileDialog(self, "Save project gcode file", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)\r
-               dlg.SetWildcard("GCode file (*.gcode)|*.gcode")\r
-               if dlg.ShowModal() != wx.ID_OK:\r
-                       dlg.Destroy()\r
-                       return\r
-               resultFilename = dlg.GetPath()\r
-               dlg.Destroy()\r
-               \r
                pspw = ProjectSliceProgressWindow(actionList, resultFilename)\r
                pspw.extruderOffset = self.extruderOffset\r
                pspw.Centre()\r
@@ -716,6 +755,13 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
                        skirtSize = profile.getProfileSettingFloat('skirt_line_count') * profile.calculateEdgeWidth() + profile.getProfileSettingFloat('skirt_gap')\r
                        extraSizeMin = extraSizeMin + util3d.Vector3(skirtSize, skirtSize, 0)\r
                        extraSizeMax = extraSizeMax + util3d.Vector3(skirtSize, skirtSize, 0)\r
+               if profile.getProfileSetting('support') != 'None':\r
+                       extraSizeMin = extraSizeMin + util3d.Vector3(3.0, 0, 0)\r
+                       extraSizeMax = extraSizeMax + util3d.Vector3(3.0, 0, 0)\r
+\r
+               if self.parent.printMode == 1:\r
+                       extraSizeMin = util3d.Vector3(6.0, 6.0, 0)\r
+                       extraSizeMax = util3d.Vector3(6.0, 6.0, 0)\r
 \r
                for item in self.parent.list:\r
                        item.validPlacement = True\r