From 4c5ff7f275f34318cce717b44059bca5f8dcf64a Mon Sep 17 00:00:00 2001 From: daid303 Date: Tue, 4 Dec 2012 18:29:50 +0100 Subject: [PATCH] Always use machine size / 2 as machine center and remove the setting. Also fixed some always-autoplace issues in the project planner. --- Cura/cura_sf/fabmetheus_utilities/settings.py | 8 ++++---- Cura/gui/configWizard.py | 6 ------ Cura/gui/flatSlicerWindow.py | 2 +- Cura/gui/mainWindow.py | 10 ---------- Cura/gui/preview3d.py | 10 +--------- Cura/gui/projectPlanner.py | 16 ++++++++++------ Cura/gui/simpleMode.py | 2 -- Cura/gui/sliceProgessPanel.py | 4 ++-- Cura/util/profile.py | 10 ++++------ Cura/util/sliceRun.py | 2 +- Cura/util/svg.py | 2 +- 11 files changed, 24 insertions(+), 48 deletions(-) diff --git a/Cura/cura_sf/fabmetheus_utilities/settings.py b/Cura/cura_sf/fabmetheus_utilities/settings.py index 92aa1099..7dddce31 100644 --- a/Cura/cura_sf/fabmetheus_utilities/settings.py +++ b/Cura/cura_sf/fabmetheus_utilities/settings.py @@ -114,8 +114,8 @@ def getProfileInformation(): 'SwapYZ': storedSetting("swap_yz"), 'Scale': storedSettingFloat("model_scale"), 'Rotate': storedSettingFloat("model_rotate_base"), - 'CenterX': storedSettingFloat("machine_center_x"), - 'CenterY': storedSettingFloat("machine_center_y"), + 'CenterX': lambda setting: profile.getProfileSettingFloat('object_center_x') if profile.getProfileSettingFloat('object_center_x') > 0 else profile.getPreferenceFloat("machine_width") / 2, + 'CenterY': lambda setting: profile.getProfileSettingFloat('object_center_y') if profile.getProfileSettingFloat('object_center_y') > 0 else profile.getPreferenceFloat("machine_depth") / 2, 'AlternativeCenterFile': storedSetting("alternative_center"), },'scale': { 'Activate_Scale': "False", @@ -176,8 +176,8 @@ def getProfileInformation(): 'Thread_Sequence_Choice': storedSetting('sequence'), },'multiply': { 'Activate_Multiply': "False", - 'Center_X_mm': storedSettingFloat("machine_center_x"), - 'Center_Y_mm': storedSettingFloat("machine_center_y"), + 'Center_X_mm': lambda setting: profile.getProfileSettingFloat('object_center_x') if profile.getProfileSettingFloat('object_center_x') > 0 else profile.getPreferenceFloat("machine_width") / 2, + 'Center_Y_mm': lambda setting: profile.getProfileSettingFloat('object_center_y') if profile.getProfileSettingFloat('object_center_y') > 0 else profile.getPreferenceFloat("machine_depth") / 2, 'Number_of_Columns_integer': storedSetting('model_multiply_x'), 'Number_of_Rows_integer': storedSetting('model_multiply_y'), 'Reverse_Sequence_every_Odd_Layer': DEFSET, diff --git a/Cura/gui/configWizard.py b/Cura/gui/configWizard.py index 50f6f8b7..5965779a 100644 --- a/Cura/gui/configWizard.py +++ b/Cura/gui/configWizard.py @@ -226,8 +226,6 @@ class RepRapInfoPage(InfoPage): profile.putPreference('machine_depth', self.machineDepth.GetValue()) profile.putPreference('machine_height', self.machineHeight.GetValue()) profile.putProfileSetting('nozzle_size', self.nozzleSize.GetValue()) - profile.putProfileSetting('machine_center_x', profile.getPreferenceFloat('machine_width') / 2) - profile.putProfileSetting('machine_center_y', profile.getPreferenceFloat('machine_depth') / 2) profile.putProfileSetting('wall_thickness', float(profile.getProfileSettingFloat('nozzle_size')) * 2) profile.putPreference('has_heated_bed', str(self.heatedBed.GetValue())) @@ -255,8 +253,6 @@ class MachineSelectPage(InfoPage): profile.putPreference('machine_height', '200') profile.putPreference('machine_type', 'ultimaker') profile.putProfileSetting('nozzle_size', '0.4') - profile.putProfileSetting('machine_center_x', '100') - profile.putProfileSetting('machine_center_y', '100') else: profile.putPreference('machine_width', '80') profile.putPreference('machine_depth', '80') @@ -264,8 +260,6 @@ class MachineSelectPage(InfoPage): profile.putPreference('machine_type', 'reprap') profile.putPreference('startMode', 'Normal') profile.putProfileSetting('nozzle_size', '0.5') - profile.putProfileSetting('machine_center_x', '40') - profile.putProfileSetting('machine_center_y', '40') profile.putProfileSetting('wall_thickness', float(profile.getProfileSetting('nozzle_size')) * 2) class FirmwareUpgradePage(InfoPage): diff --git a/Cura/gui/flatSlicerWindow.py b/Cura/gui/flatSlicerWindow.py index 5f28767b..4c8f1d91 100644 --- a/Cura/gui/flatSlicerWindow.py +++ b/Cura/gui/flatSlicerWindow.py @@ -84,7 +84,7 @@ class flatSlicerWindow(wx.Frame): if dlg.ShowModal() == wx.ID_OK: self.filename = dlg.GetPath() self.svg = svg.SVG(self.filename) - self.svg.center(complex(profile.getProfileSettingFloat('machine_center_x'), profile.getProfileSettingFloat('machine_center_y'))) + self.svg.center(complex(profile.getPreferenceFloat('machine_width')/2, profile.getPreferenceFloat('machine_depth')/2)) self.preview.Refresh() dlg.Destroy() diff --git a/Cura/gui/mainWindow.py b/Cura/gui/mainWindow.py index 98a57c5d..f20e78d4 100644 --- a/Cura/gui/mainWindow.py +++ b/Cura/gui/mainWindow.py @@ -182,12 +182,6 @@ class mainWindow(configBase.configWindowBase): configBase.TitleRow(left, "Machine size") c = configBase.SettingRow(left, "Nozzle size (mm)", 'nozzle_size', '0.4', 'The nozzle size is very important, this is used to calculate the line width of the infill, and used to calculate the amount of outside wall lines and thickness for the wall thickness you entered in the print settings.') validators.validFloat(c, 0.1, 10.0) - c = configBase.SettingRow(left, "Machine center X (mm)", 'machine_center_x', '100', 'The center of your machine, your print will be placed at this location') - validators.validInt(c, 10) - configBase.settingNotify(c, self.preview3d.updateCenterX) - c = configBase.SettingRow(left, "Machine center Y (mm)", 'machine_center_y', '100', 'The center of your machine, your print will be placed at this location') - validators.validInt(c, 10) - configBase.settingNotify(c, self.preview3d.updateCenterY) configBase.TitleRow(left, "Skirt") c = configBase.SettingRow(left, "Line count", 'skirt_line_count', '1', 'The skirt is a line drawn around the object at the first layer. This helps to prime your extruder, and to see if the object fits on your platform.\nSetting this to 0 will disable the skirt. Multiple skirt lines can help priming your extruder better for small objects.') @@ -332,10 +326,6 @@ class mainWindow(configBase.configWindowBase): dlg.Destroy() if result: profile.resetGlobalProfile() - if profile.getPreference('machine_type') == 'reprap': - profile.putProfileSetting('nozzle_size', '0.5') - profile.putProfileSetting('machine_center_x', '40') - profile.putProfileSetting('machine_center_y', '40') self.updateProfileToControls() def OnBatchRun(self, e): diff --git a/Cura/gui/preview3d.py b/Cura/gui/preview3d.py index 0fe9276e..2e62d41f 100644 --- a/Cura/gui/preview3d.py +++ b/Cura/gui/preview3d.py @@ -45,7 +45,7 @@ class previewPanel(wx.Panel): self.objectsMaxV = None self.loadThread = None self.machineSize = util3d.Vector3(profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth'), profile.getPreferenceFloat('machine_height')) - self.machineCenter = util3d.Vector3(float(profile.getProfileSetting('machine_center_x')), float(profile.getProfileSetting('machine_center_y')), 0) + self.machineCenter = util3d.Vector3(self.machineSize.x / 2, self.machineSize.y / 2, 0) self.glCanvas = PreviewGLCanvas(self) #Create the popup window @@ -231,14 +231,6 @@ class previewPanel(wx.Panel): def OnLayerNrChange(self, e): self.glCanvas.Refresh() - - def updateCenterX(self): - self.machineCenter.x = profile.getProfileSettingFloat('machine_center_x') - self.glCanvas.Refresh() - - def updateCenterY(self): - self.machineCenter.y = profile.getProfileSettingFloat('machine_center_y') - self.glCanvas.Refresh() def setViewMode(self, mode): if mode == "Normal": diff --git a/Cura/gui/projectPlanner.py b/Cura/gui/projectPlanner.py index c83e1af1..a6b4244a 100644 --- a/Cura/gui/projectPlanner.py +++ b/Cura/gui/projectPlanner.py @@ -596,8 +596,8 @@ class projectPlanner(wx.Frame): for item in self.list: if item.profile != None and os.path.isfile(item.profile): profile.loadGlobalProfile(item.profile) - put('machine_center_x', item.centerX - self.extruderOffset[item.extruder][0]) - put('machine_center_y', item.centerY - self.extruderOffset[item.extruder][1]) + put('object_center_x', item.centerX - self.extruderOffset[item.extruder][0]) + put('object_center_y', item.centerY - self.extruderOffset[item.extruder][1]) put('model_scale', item.scale) put('flip_x', item.flipX) put('flip_y', item.flipY) @@ -639,8 +639,8 @@ class projectPlanner(wx.Frame): action = Action() action.sliceCmd = sliceRun.getSliceCommand(resultFilename + "_temp_.stl") - action.centerX = profile.getProfileSettingFloat('machine_center_x') - action.centerY = profile.getProfileSettingFloat('machine_center_y') + action.centerX = profile.getPreferenceFloat('machine_width') / 2 + action.centerY = profile.getPreferenceFloat('machine_depth') / 2 action.temperature = profile.getProfileSettingFloat('print_temperature') action.extruder = 0 action.filename = resultFilename + "_temp_.stl" @@ -672,6 +672,8 @@ class projectPlanner(wx.Frame): return self.selection.rotate = float(self.rotateCtrl.GetValue()) self.selection.updateModelTransform() + if self.alwaysAutoPlace: + self.OnAutoPlace(None) self.preview.Refresh() def OnExtruderChange(self, e): @@ -689,6 +691,8 @@ class projectPlanner(wx.Frame): self.selection.swapXZ = self.swapXZ.GetValue() self.selection.swapYZ = self.swapYZ.GetValue() self.selection.updateModelTransform() + if self.alwaysAutoPlace: + self.OnAutoPlace(None) self.preview.Refresh() def getExtraHeadSize(self): @@ -982,8 +986,8 @@ class ProjectSliceProgressWindow(wx.Frame): line = p.stdout.readline() self.returnCode = p.wait() - put('machine_center_x', action.centerX - self.extruderOffset[action.extruder][0]) - put('machine_center_y', action.centerY - self.extruderOffset[action.extruder][1]) + put('object_center_x', action.centerX - self.extruderOffset[action.extruder][0]) + put('object_center_y', action.centerY - self.extruderOffset[action.extruder][1]) put('clear_z', action.clearZ) put('extruder', action.extruder) put('print_temperature', action.temperature) diff --git a/Cura/gui/simpleMode.py b/Cura/gui/simpleMode.py index 1c0e5867..69eb7b44 100644 --- a/Cura/gui/simpleMode.py +++ b/Cura/gui/simpleMode.py @@ -187,8 +187,6 @@ class simpleModeWindow(configBase.configWindowBase): put('print_speed', '50') put('print_temperature', '220') put('support', 'None') - #put('machine_center_x', '100') - #put('machine_center_y', '100') put('retraction_enable', 'False') put('retraction_min_travel', '5.0') put('retraction_speed', '40.0') diff --git a/Cura/gui/sliceProgessPanel.py b/Cura/gui/sliceProgessPanel.py index fce06a4b..52411cf4 100644 --- a/Cura/gui/sliceProgessPanel.py +++ b/Cura/gui/sliceProgessPanel.py @@ -46,8 +46,8 @@ class sliceProgessPanel(wx.Panel): if idx > 0: profile.setTempOverride('fan_enabled', 'False') profile.setTempOverride('skirt_line_count', '0') - profile.setTempOverride('machine_center_x', profile.getProfileSettingFloat('machine_center_x') - profile.getPreferenceFloat('extruder_offset_x%d' % (idx))) - profile.setTempOverride('machine_center_y', profile.getProfileSettingFloat('machine_center_y') - profile.getPreferenceFloat('extruder_offset_y%d' % (idx))) + profile.setTempOverride('object_center_x', profile.getPreferenceFloat('machine_width') / 2 - profile.getPreferenceFloat('extruder_offset_x%d' % (idx))) + profile.setTempOverride('object_center_y', profile.getPreferenceFloat('machine_depth') / 2 - profile.getPreferenceFloat('extruder_offset_y%d' % (idx))) profile.setTempOverride('alternative_center', self.filelist[0]) if len(self.filelist) > 1: profile.setTempOverride('add_start_end_gcode', 'False') diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 142df2ee..fc9752aa 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -31,8 +31,6 @@ profileDefaultSettings = { 'support': 'None', 'filament_diameter': '2.89', 'filament_density': '1.00', - 'machine_center_x': '100', - 'machine_center_y': '100', 'retraction_min_travel': '5.0', 'retraction_enable': 'False', 'retraction_speed': '40.0', @@ -102,9 +100,6 @@ G1 Z15.0 F{max_z_speed} ;move the platform down 15mm G92 E0 ;zero the extruded length G1 F200 E3 ;extrude 3mm of feed stock G92 E0 ;zero the extruded length again - -;go to the middle of the platform (disabled, as there is no need to go to the center) -;G1 X{machine_center_x} Y{machine_center_y} F{travel_speed} G1 F{travel_speed} """, ####################################################################################### @@ -137,7 +132,7 @@ G90 ;absolute positioning G1 Z{clear_z} F{max_z_speed} G92 E0 -G1 X{machine_center_x} Y{machine_center_y} F{travel_speed} +G1 X{object_center_x} Y{object_center_x} F{travel_speed} G1 F200 E6 G92 E0 """, @@ -219,6 +214,9 @@ def resetGlobalProfile(): global globalProfileParser globalProfileParser = ConfigParser.ConfigParser() + if getPreference('machine_type') == 'reprap': + putProfileSetting('nozzle_size', '0.5') + def saveGlobalProfile(filename): #Save the current profile to an ini file globalProfileParser.write(open(filename, 'w')) diff --git a/Cura/util/sliceRun.py b/Cura/util/sliceRun.py index 6afeb4a9..3bd6942d 100644 --- a/Cura/util/sliceRun.py +++ b/Cura/util/sliceRun.py @@ -115,7 +115,7 @@ def getSliceCommand(filename): cmd = [slic3rExe, '--output-filename-format', '[input_filename_base].gcode', '--nozzle-diameter', str(profile.calculateEdgeWidth()), - '--print-center', '%s,%s' % (profile.getProfileSetting('machine_center_x'), profile.getProfileSetting('machine_center_y')), + '--print-center', '%s,%s' % (profile.getPreferenceFloat('machine_width') / 2, profile.getPreferenceFloat('machine_depth') / 2), '--z-offset', '0', '--gcode-flavor', 'reprap', '--gcode-comments', diff --git a/Cura/util/svg.py b/Cura/util/svg.py index c68206f1..6485e930 100644 --- a/Cura/util/svg.py +++ b/Cura/util/svg.py @@ -215,7 +215,7 @@ if __name__ == '__main__': f.write(';TYPE:CUSTOM\n') f.write(profile.getAlterationFileContents('start.gcode')) - svg.center(complex(profile.getProfileSettingFloat('machine_center_x'), profile.getProfileSettingFloat('machine_center_y'))) + svg.center(complex(profile.getPreferenceFloat('machine_width') / 2, profile.getPreferenceFloat('machine_depth') / 2)) layerThickness = 0.4 filamentRadius = profile.getProfileSettingFloat('filament_diameter') / 2 -- 2.30.2