diff --git a/cura/ConvexHullDecorator.py b/cura/ConvexHullDecorator.py index 9edb111c77..1f1bc5db34 100644 --- a/cura/ConvexHullDecorator.py +++ b/cura/ConvexHullDecorator.py @@ -14,18 +14,10 @@ class ConvexHullDecorator(SceneNodeDecorator): self._convex_hull_node = None self._convex_hull_job = None - settings = Application.getInstance().getMachineManager().getActiveMachineInstance() - print_sequence_setting = settings.getSettingByKey("print_sequence") - if print_sequence_setting: - print_sequence_setting.valueChanged.connect(self._onPrintSequenceSettingChanged) - - def _onPrintSequenceSettingChanged(self, setting): - if self._convex_hull_job: - self._convex_hull_job.cancel() - self.setConvexHull(None) - if self._convex_hull_node: - self._convex_hull_node.setParent(None) - self._convex_hull_node = None + + self._profile = None + Application.getInstance().getMachineManager().activeProfileChanged.connect(self._onActiveProfileChanged) + self._onActiveProfileChanged() def getConvexHull(self): return self._convex_hull @@ -61,4 +53,20 @@ class ConvexHullDecorator(SceneNodeDecorator): def setConvexHullNode(self, node): self._convex_hull_node = node - \ No newline at end of file + def _onActiveProfileChanged(self): + if self._profile: + self._profile.settingValueChanged.disconnect(self._onSettingValueChanged) + + self._profile = Application.getInstance().getMachineManager().getActiveProfile() + + if self._profile: + self._profile.settingValueChanged.connect(self._onSettingValueChanged) + + def _onSettingValueChanged(self, setting): + if setting == "print_sequence": + if self._convex_hull_job: + self._convex_hull_job.cancel() + self.setConvexHull(None) + if self._convex_hull_node: + self._convex_hull_node.setParent(None) + self._convex_hull_node = None diff --git a/cura/ConvexHullJob.py b/cura/ConvexHullJob.py index 1e87892504..f858d142d4 100644 --- a/cura/ConvexHullJob.py +++ b/cura/ConvexHullJob.py @@ -46,14 +46,14 @@ class ConvexHullJob(Job): # Then, do a Minkowski hull with a simple 1x1 quad to outset and round the normal convex hull. # This is done because of rounding errors. hull = hull.getMinkowskiHull(Polygon(numpy.array([[-1, -1], [-1, 1], [1, 1], [1, -1]], numpy.float32))) - settings = Application.getInstance().getMachineManager().getActiveMachineInstance() - - if settings.getSettingValueByKey("print_sequence") == "One at a time" and not self._node.getParent().callDecoration("isGroup"): + + profile = Application.getInstance().getMachineManager().getActiveProfile() + if profile.getSettingValue("print_sequence") == "one_at_a_time" and not self._node.getParent().callDecoration("isGroup"): # Printing one at a time and it's not an object in a group self._node.callDecoration("setConvexHullBoundary", copy.deepcopy(hull)) - head_hull = hull.getMinkowskiHull(Polygon(numpy.array(settings.getSettingValueByKey("machine_head_with_fans_polygon"),numpy.float32))) + head_hull = hull.getMinkowskiHull(Polygon(numpy.array(profile.getSettingValue("machine_head_with_fans_polygon"),numpy.float32))) self._node.callDecoration("setConvexHullHead", head_hull) - hull = hull.getMinkowskiHull(Polygon(numpy.array(settings.getSettingValueByKey("machine_head_polygon"),numpy.float32))) + hull = hull.getMinkowskiHull(Polygon(numpy.array(profile.getSettingValue("machine_head_polygon"),numpy.float32))) hull_node = ConvexHullNode.ConvexHullNode(self._node, hull, Application.getInstance().getController().getScene().getRoot()) self._node.callDecoration("setConvexHullNode", hull_node) self._node.callDecoration("setConvexHull", hull) @@ -67,4 +67,3 @@ class ConvexHullJob(Job): hull_node = self._node.getParent().callDecoration("getConvexHullNode") if hull_node: hull_node.setParent(None) -