From 67a0ea194fb37e4195b9b8106065040db495ca37 Mon Sep 17 00:00:00 2001 From: daid303 Date: Fri, 11 Jan 2013 12:05:56 +0100 Subject: [PATCH] Add option to have the center of the printer at 0,0 for RoStock printers. #310 #266 --- Cura/gui/configWizard.py | 3 +++ Cura/gui/preview3d.py | 6 +++++- Cura/gui/projectPlanner.py | 6 +++++- Cura/slice/__main__.py | 2 ++ Cura/slice/cura_sf/fabmetheus_utilities/settings.py | 4 ++-- Cura/util/profile.py | 3 +++ 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Cura/gui/configWizard.py b/Cura/gui/configWizard.py index e6ae89fb..5b007acd 100644 --- a/Cura/gui/configWizard.py +++ b/Cura/gui/configWizard.py @@ -241,6 +241,7 @@ class RepRapInfoPage(InfoPage): self.machineHeight = self.AddLabelTextCtrl('Machine height (mm)', '60') self.nozzleSize = self.AddLabelTextCtrl('Nozzle size (mm)', '0.5') self.heatedBed = self.AddCheckbox('Heated bed') + self.HomeAtCenter = self.AddCheckbox('Bed center is 0,0,0 (RoStock)') def StoreData(self): profile.putPreference('machine_width', self.machineWidth.GetValue()) @@ -249,6 +250,7 @@ class RepRapInfoPage(InfoPage): profile.putProfileSetting('nozzle_size', self.nozzleSize.GetValue()) profile.putProfileSetting('wall_thickness', float(profile.getProfileSettingFloat('nozzle_size')) * 2) profile.putPreference('has_heated_bed', str(self.heatedBed.GetValue())) + profile.putPreference('machine_center_is_zero', str(self.HomeAtCenter.GetValue())) class MachineSelectPage(InfoPage): @@ -274,6 +276,7 @@ class MachineSelectPage(InfoPage): profile.putPreference('machine_depth', '205') profile.putPreference('machine_height', '200') profile.putPreference('machine_type', 'ultimaker') + profile.putPreference('machine_center_is_zero', 'False') profile.putProfileSetting('nozzle_size', '0.4') else: profile.putPreference('machine_width', '80') diff --git a/Cura/gui/preview3d.py b/Cura/gui/preview3d.py index 527e47bb..fecda902 100644 --- a/Cura/gui/preview3d.py +++ b/Cura/gui/preview3d.py @@ -657,7 +657,10 @@ class PreviewGLCanvas(glcanvas.GLCanvas): glPopMatrix() - if self.parent.gcode != None and (self.viewMode == "GCode" or self.viewMode == "Mixed"): + if self.parent.gcode is not None and (self.viewMode == "GCode" or self.viewMode == "Mixed"): + glPushMatrix() + if profile.getPreference('machine_center_is_zero') == 'True': + glTranslate(self.parent.machineCenter.x, self.parent.machineCenter.y, 0) glEnable(GL_COLOR_MATERIAL) glEnable(GL_LIGHTING) drawUpToLayer = min(self.gcodeDisplayListMade, self.parent.layerSpin.GetValue() + 1) @@ -680,6 +683,7 @@ class PreviewGLCanvas(glcanvas.GLCanvas): glDisable(GL_COLOR_MATERIAL) glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [0.2, 0.2, 0.2, 1.0]); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [0.8, 0.8, 0.8, 1.0]); + glPopMatrix() glColor3f(1.0,1.0,1.0) glPushMatrix() diff --git a/Cura/gui/projectPlanner.py b/Cura/gui/projectPlanner.py index 96427066..4ce44aa4 100644 --- a/Cura/gui/projectPlanner.py +++ b/Cura/gui/projectPlanner.py @@ -594,7 +594,11 @@ class projectPlanner(wx.Frame): positionList = [] for item in self.list: fileList.append(item.filename) - positionList.append([item.centerX, item.centerY] + (item.mesh.matrix * item.scale).reshape((9,)).tolist()) + if profile.getPreference('machine_center_is_zero') == 'True': + pos = [item.centerX - self.machineSize[0] / 2, item.centerY - self.machineSize[1] / 2] + else: + pos = [item.centerX, item.centerY] + positionList.append(pos + (item.mesh.matrix * item.scale).reshape((9,)).tolist()) sliceCommand = sliceRun.getSliceCommand(resultFilename, fileList, positionList) else: self._saveCombinedSTL(resultFilename + "_temp_.stl") diff --git a/Cura/slice/__main__.py b/Cura/slice/__main__.py index bd2a0bdb..15eee891 100644 --- a/Cura/slice/__main__.py +++ b/Cura/slice/__main__.py @@ -38,6 +38,8 @@ def main(): position += [0,0,1] filenames = fixUTF8(args[idx + 1]).split('|') + profile.setTempOverride('object_center_x', position[0]) + profile.setTempOverride('object_center_y', position[1]) if idx == 0: resultFile.write(';TYPE:CUSTOM\n') resultFile.write(profile.getAlterationFileContents('start.gcode').replace('?filename?', ' '.join(filenames).encode('ascii', 'replace'))) diff --git a/Cura/slice/cura_sf/fabmetheus_utilities/settings.py b/Cura/slice/cura_sf/fabmetheus_utilities/settings.py index df816e01..5d4befdb 100644 --- a/Cura/slice/cura_sf/fabmetheus_utilities/settings.py +++ b/Cura/slice/cura_sf/fabmetheus_utilities/settings.py @@ -107,8 +107,8 @@ def getProfileInformation(): 'Unproven_Mesh': DEFSET, 'SVG_Viewer': DEFSET, 'ObjectMatrix': storedSetting("object_matrix"), - '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, + 'CenterX': lambda setting: profile.getProfileSettingFloat('object_center_x'), + 'CenterY': lambda setting: profile.getProfileSettingFloat('object_center_y'), 'AlternativeCenterFile': storedSetting("alternative_center"), },'scale': { 'Activate_Scale': "False", diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 48453d9f..a015e513 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -154,6 +154,7 @@ preferencesDefaultSettings = { 'machine_depth': '205', 'machine_height': '200', 'machine_type': 'unknown', + 'machine_center_is_zero': 'False', 'ultimaker_extruder_upgrade': 'False', 'has_heated_bed': 'False', 'extruder_amount': '1', @@ -425,6 +426,8 @@ def calculateSolidLayerCount(): return int(math.ceil(solidThickness / layerHeight - 0.0001)) def getMachineCenterCoords(): + if getPreference('machine_center_is_zero') == 'True': + return [0, 0] return [getPreferenceFloat('machine_width') / 2, getPreferenceFloat('machine_depth') / 2] def getObjectMatrix(): -- 2.30.2