chiark / gitweb /
Add option to have the center of the printer at 0,0 for RoStock printers. #310 #266
authordaid303 <daid303@gmail.com>
Fri, 11 Jan 2013 11:05:56 +0000 (12:05 +0100)
committerdaid303 <daid303@gmail.com>
Fri, 11 Jan 2013 11:05:56 +0000 (12:05 +0100)
Cura/gui/configWizard.py
Cura/gui/preview3d.py
Cura/gui/projectPlanner.py
Cura/slice/__main__.py
Cura/slice/cura_sf/fabmetheus_utilities/settings.py
Cura/util/profile.py

index e6ae89fbb13c7e8d0985a75363e2b414c5040b6a..5b007acdfb2a8db09e3a05e115f8dba14423c2d9 100644 (file)
@@ -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')
index 527e47bb7f22649d582e25d9cccbfd4b8b713468..fecda902a7ae7aff30f3ad52fc8cfc439818f553 100644 (file)
@@ -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()
index 96427066d6f74cb36aa7260d839cbbd16c88c3d6..4ce44aa4df25672c65b1e0ee07dd279b53afbb29 100644 (file)
@@ -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")
index bd2a0bdb69ae81a7d745628674247c2a2ec1abf2..15eee89172067f16f5af0f753d397dd5bf786bfd 100644 (file)
@@ -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')))
index df816e0107e1888abed787305f8e1534b0421e66..5d4befdb8a8cca8fe76db0528357681345468b12 100644 (file)
@@ -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",
index 48453d9fc5baf726e98bf62cf13f7fbd0e5b386e..a015e5136afe7fce14bf5c5abc4f148a209db58b 100644 (file)
@@ -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():