diff options
author | fieldOfView <aldo@fieldofview.com> | 2020-03-22 20:23:32 +0300 |
---|---|---|
committer | fieldOfView <aldo@fieldofview.com> | 2020-03-22 20:23:32 +0300 |
commit | 6e09e9821f204656d380bf775bec4e71dfc9acd6 (patch) | |
tree | 65bbbc5e1532549cf731b415913310514804db04 /cura/Scene | |
parent | 485e37e7f5038ef7dd5ccb8dcc97b48c435b7fb5 (diff) |
Show support settings when support meshes are present in the scene
Diffstat (limited to 'cura/Scene')
-rw-r--r-- | cura/Scene/CuraSceneController.py | 31 | ||||
-rw-r--r-- | cura/Scene/CuraSceneNode.py | 6 |
2 files changed, 36 insertions, 1 deletions
diff --git a/cura/Scene/CuraSceneController.py b/cura/Scene/CuraSceneController.py index 36d9e68c8f..f97fde0f7e 100644 --- a/cura/Scene/CuraSceneController.py +++ b/cura/Scene/CuraSceneController.py @@ -6,13 +6,15 @@ from PyQt5.QtWidgets import QApplication from UM.Scene.Camera import Camera from cura.UI.ObjectsModel import ObjectsModel from cura.Machines.Models.MultiBuildPlateModel import MultiBuildPlateModel +from cura.Scene.CuraSceneNode import CuraSceneNode from UM.Application import Application from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Scene.SceneNode import SceneNode from UM.Scene.Selection import Selection from UM.Signal import Signal - +from UM.Settings.SettingFunction import SettingFunction +from UM.Settings.ContainerRegistry import ContainerRegistry class CuraSceneController(QObject): activeBuildPlateChanged = Signal() @@ -43,6 +45,24 @@ class CuraSceneController(QObject): self._change_timer.start() def updateMaxBuildPlate(self, *args): + global_stack = Application.getInstance().getGlobalContainerStack() + if global_stack: + scene_has_support_meshes = self._sceneHasSupportMeshes() # TODO: see if this can be cached + if scene_has_support_meshes != global_stack.getProperty("support_meshes_present", "value"): + # adjust the setting without having the setting value in an InstanceContainer + setting_definitions = global_stack.definition.findDefinitions(key="support_meshes_present") + if setting_definitions: + relations = setting_definitions[0].relations + definition_dict = setting_definitions[0].serialize_to_dict() + definition_dict["enabled"] = False + definition_dict["default_value"] = scene_has_support_meshes + setting_definitions[0].deserialize(definition_dict) + setting_definitions[0]._relations = relations # TODO: find a better way to restore relations + + # notify relations that the setting has changed + for relation in relations: + global_stack.propertyChanged.emit(relation.target.key, "enabled") + max_build_plate = self._calcMaxBuildPlate() changed = False if max_build_plate != self._max_build_plate: @@ -72,6 +92,15 @@ class CuraSceneController(QObject): max_build_plate = max(build_plate_number, max_build_plate) return max_build_plate + def _sceneHasSupportMeshes(self): + root = Application.getInstance().getController().getScene().getRoot() + for node in root.getAllChildren(): + if isinstance(node, CuraSceneNode): + per_mesh_stack = node.callDecoration("getStack") + if per_mesh_stack and per_mesh_stack.getProperty("support_mesh", "value"): + return True + return False + ## Either select or deselect an item @pyqtSlot(int) def changeSelection(self, index): diff --git a/cura/Scene/CuraSceneNode.py b/cura/Scene/CuraSceneNode.py index eb609def5a..df01c79a29 100644 --- a/cura/Scene/CuraSceneNode.py +++ b/cura/Scene/CuraSceneNode.py @@ -36,6 +36,12 @@ class CuraSceneNode(SceneNode): def isSelectable(self) -> bool: return super().isSelectable() and self.callDecoration("getBuildPlateNumber") == cura.CuraApplication.CuraApplication.getInstance().getMultiBuildPlateModel().activeBuildPlate + def isSupportMesh(self) -> bool: + per_mesh_stack = self.callDecoration("getStack") + if not per_mesh_stack: + return False + return per_mesh_stack.getProperty("support_mesh", "value") + ## Get the extruder used to print this node. If there is no active node, then the extruder in position zero is returned # TODO The best way to do it is by adding the setActiveExtruder decorator to every node when is loaded def getPrintingExtruder(self) -> Optional[ExtruderStack]: |