chiark / gitweb /
Make sure the print fits on the bed with dual-extrusion-support.
authordaid <daid303@gmail.com>
Wed, 4 Dec 2013 09:18:53 +0000 (10:18 +0100)
committerdaid <daid303@gmail.com>
Wed, 4 Dec 2013 09:18:53 +0000 (10:18 +0100)
Cura/gui/sceneView.py
Cura/util/objectScene.py
Cura/util/profile.py
Cura/util/sliceEngine.py

index c25cbc90acdc3e90aa8a1d71db3ed48c8285d757..c7ad9c8573819f808575fcee96846a2c1ae011fc 100644 (file)
@@ -611,7 +611,7 @@ class SceneView(openglGui.glGuiPanel):
        def _selectObject(self, obj, zoom = True):
                if obj != self._selectedObj:
                        self._selectedObj = obj
-                       self.updateProfileToControls()
+                       self.updateModelSettingsToControls()
                        self.updateToolButtons()
                if zoom and obj is not None:
                        newViewPos = numpy.array([obj.getPosition()[0], obj.getPosition()[1], obj.getSize()[2] / 2])
@@ -634,7 +634,9 @@ class SceneView(openglGui.glGuiPanel):
                self._objColors[2] = profile.getPreferenceColour('model_colour3')
                self._objColors[3] = profile.getPreferenceColour('model_colour4')
                self._scene.updateMachineDimensions()
+               self.updateModelSettingsToControls()
 
+       def updateModelSettingsToControls(self):
                if self._selectedObj is not None:
                        scale = self._selectedObj.getScale()
                        size = self._selectedObj.getSize()
index 63b1d0ede24f1e7661119b7246fb261089a298be..b229a70923edc67a640ad0298f224c3754245b80 100644 (file)
@@ -90,6 +90,7 @@ class Scene(object):
                self._sizeOffsets = numpy.array([0.0,0.0], numpy.float32)
                self._machineSize = numpy.array([100,100,100], numpy.float32)
                self._headSizeOffsets = numpy.array([18.0,18.0], numpy.float32)
+               self._minExtruderCount = None
                self._extruderOffset = [numpy.array([0,0], numpy.float32)] * 4
 
                #Print order variables
@@ -107,14 +108,18 @@ class Scene(object):
        # Size offsets are offsets caused by brim, skirt, etc.
        def updateSizeOffsets(self, force=False):
                newOffsets = numpy.array(profile.calculateObjectSizeOffsets(), numpy.float32)
-               if not force and numpy.array_equal(self._sizeOffsets, newOffsets):
+               minExtruderCount = profile.minimalExtruderCount()
+               if not force and numpy.array_equal(self._sizeOffsets, newOffsets) and self._minExtruderCount == minExtruderCount:
                        return
                self._sizeOffsets = newOffsets
+               self._minExtruderCount = minExtruderCount
 
                extends = [numpy.array([[-newOffsets[0],-newOffsets[1]],[ newOffsets[0],-newOffsets[1]],[ newOffsets[0], newOffsets[1]],[-newOffsets[0], newOffsets[1]]], numpy.float32)]
                for n in xrange(1, 4):
                        headOffset = numpy.array([[0, 0], [-profile.getMachineSettingFloat('extruder_offset_x%d' % (n)), -profile.getMachineSettingFloat('extruder_offset_y%d' % (n))]], numpy.float32)
                        extends.append(polygon.minkowskiHull(extends[n-1], headOffset))
+               if minExtruderCount > 1:
+                       extends[0] = extends[1]
 
                for obj in self._objectList:
                        obj.setPrintAreaExtends(extends[len(obj._meshList) - 1])
index a2f0255a17a5ed5818f67907b4a6bef1aa3391ed..d6239dc4a0758d095874e4946570d1c373c9f107 100644 (file)
@@ -895,6 +895,16 @@ def getMachineSizePolygons():
                ret.append(numpy.array([[ size[0]/2, size[1]/2],[ size[0]/2-w-2, size[1]/2], [ size[0]/2-w, size[1]/2-h],[ size[0]/2, size[1]/2-h]], numpy.float32))
        return ret
 
+#returns the number of extruders minimal used. Normally this returns 1, but with dual-extrusion support material it returns 2
+def minimalExtruderCount():
+       if int(getMachineSetting('extruder_amount')) < 2:
+               return 1
+       if getProfileSetting('support') == 'None':
+               return 1
+       if getProfileSetting('support_dual_extrusion') == 'Second extruder':
+               return 2
+       return 1
+
 #########################################################
 ## Alteration file functions
 #########################################################
index 9cd8fc31a8b3a17ca290080adb2339891bd88a17..87c539fec2351a9a1f2d3760d166d0b16f40f47c 100644 (file)
@@ -117,8 +117,8 @@ class Slicer(object):
                for obj in scene.objects():
                        if scene.checkPlatform(obj):
                                extruderCount = max(extruderCount, len(obj._meshList))
-               if profile.getProfileSetting('support_dual_extrusion') == 'Second extruder':
-                       extruderCount = max(extruderCount, 2)
+
+               extruderCount = max(extruderCount, profile.minimalExtruderCount())
 
                commandList = [getEngineFilename(), '-vv']
                for k, v in self._engineSettings(extruderCount).iteritems():
@@ -280,7 +280,7 @@ class Slicer(object):
                        'supportLineDistance': int(100 * profile.calculateEdgeWidth() * 1000 / profile.getProfileSettingFloat('support_fill_rate')) if profile.getProfileSettingFloat('support_fill_rate') > 0 else -1,
                        'supportXYDistance': int(1000 * profile.getProfileSettingFloat('support_xy_distance')),
                        'supportZDistance': int(1000 * profile.getProfileSettingFloat('support_z_distance')),
-                       'supportExtruder': 0 if profile.getProfileSetting('support_dual_extrusion') == 'First extruder' else (1 if profile.getProfileSetting('support_dual_extrusion') == 'Second extruder' else -1),
+                       'supportExtruder': 0 if profile.getProfileSetting('support_dual_extrusion') == 'First extruder' else (1 if profile.getProfileSetting('support_dual_extrusion') == 'Second extruder' and profile.minimalExtruderCount() > 1 else -1),
                        'retractionAmount': int(profile.getProfileSettingFloat('retraction_amount') * 1000) if profile.getProfileSetting('retraction_enable') == 'True' else 0,
                        'retractionSpeed': int(profile.getProfileSettingFloat('retraction_speed')),
                        'retractionMinimalDistance': int(profile.getProfileSettingFloat('retraction_min_travel') * 1000),