Browse Source

Fix ConvexHull{Decorator,Job} to work with the new profile structure

Arjen Hiemstra 9 years ago
parent
commit
47e96a9e2a
2 changed files with 26 additions and 19 deletions
  1. 21 13
      cura/ConvexHullDecorator.py
  2. 5 6
      cura/ConvexHullJob.py

+ 21 - 13
cura/ConvexHullDecorator.py

@@ -14,18 +14,10 @@ class ConvexHullDecorator(SceneNodeDecorator):
         
         
         self._convex_hull_node = None
         self._convex_hull_node = None
         self._convex_hull_job = 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):
     def getConvexHull(self):
         return self._convex_hull
         return self._convex_hull
@@ -61,4 +53,20 @@ class ConvexHullDecorator(SceneNodeDecorator):
     def setConvexHullNode(self, node):
     def setConvexHullNode(self, node):
         self._convex_hull_node = node
         self._convex_hull_node = node
             
             
-    
+    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

+ 5 - 6
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.
         # 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.
         # This is done because of rounding errors.
         hull = hull.getMinkowskiHull(Polygon(numpy.array([[-1, -1], [-1, 1], [1, 1], [1, -1]], numpy.float32)))
         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
             # Printing one at a time and it's not an object in a group
             self._node.callDecoration("setConvexHullBoundary", copy.deepcopy(hull))
             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)
             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())
         hull_node = ConvexHullNode.ConvexHullNode(self._node, hull, Application.getInstance().getController().getScene().getRoot())
         self._node.callDecoration("setConvexHullNode", hull_node)
         self._node.callDecoration("setConvexHullNode", hull_node)
         self._node.callDecoration("setConvexHull", hull)
         self._node.callDecoration("setConvexHull", hull)
@@ -67,4 +67,3 @@ class ConvexHullJob(Job):
             hull_node = self._node.getParent().callDecoration("getConvexHullNode")
             hull_node = self._node.getParent().callDecoration("getConvexHullNode")
             if hull_node:
             if hull_node:
                 hull_node.setParent(None)
                 hull_node.setParent(None)
-