From 9c2fd1c9d421a4ffb1a60d8e6eb10a62dd45cf3a Mon Sep 17 00:00:00 2001 From: Tim Kuipers Date: Fri, 3 Jan 2020 15:13:24 +0100 Subject: [PATCH 1/3] automatically add shell thickness to stack and set to zero for infill meshes and remove when unmodified and we change to another mesh type --- .../PerObjectSettingsTool/PerObjectSettingsTool.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py index b2eb925a6d..8f2164261b 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py @@ -68,7 +68,8 @@ class PerObjectSettingsTool(Tool): ## Returns True when the mesh_type was changed, False when current mesh_type == mesh_type def setMeshType(self, mesh_type: str) -> bool: - if self.getMeshType() == mesh_type: + old_mesh_type = self.getMeshType() + if old_mesh_type == mesh_type: return False selected_object = Selection.getSelectedObject(0) @@ -94,6 +95,17 @@ class PerObjectSettingsTool(Tool): new_instance.resetState() # Ensure that the state is not seen as a user state. settings.addInstance(new_instance) + for property_key in ["top_bottom_thickness", "wall_thickness"]: + if mesh_type == "infill_mesh": + if not settings.getInstance(property_key): + definition = stack.getSettingDefinition(property_key) + new_instance = SettingInstance(definition, settings) + new_instance.setProperty("value", 0) + new_instance.resetState() # Ensure that the state is not seen as a user state. + settings.addInstance(new_instance) + elif old_mesh_type == "infill_mesh" and settings.getInstance(property_key) and settings.getProperty(property_key, "value") == 0: + settings.removeInstance(property_key) + self.propertyChanged.emit() return True From 3b235d553605e2583be6b068159ecfea692b92ad Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 13 Feb 2020 13:08:32 +0100 Subject: [PATCH 2/3] Make settings visible too after adding them Contributes to issue CURA-7211. --- .../PerObjectSettingVisibilityHandler.py | 5 ++++- .../PerObjectSettingsTool/PerObjectSettingsTool.py | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py b/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py index 61d0dbc0f0..fb78134833 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py +++ b/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py @@ -1,10 +1,11 @@ -# Copyright (c) 2016 Ultimaker B.V. +# Copyright (c) 2020 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. from PyQt5.QtCore import pyqtProperty from UM.FlameProfiler import pyqtSlot from UM.Application import Application +from UM.PluginRegistry import PluginRegistry from UM.Settings.ContainerRegistry import ContainerRegistry from UM.Settings.SettingInstance import SettingInstance from UM.Logger import Logger @@ -24,6 +25,8 @@ class PerObjectSettingVisibilityHandler(UM.Settings.Models.SettingVisibilityHand self._node = None self._stack = None + PluginRegistry.getInstance().getPluginObject("PerObjectSettingsTool").visibility_handler = self + # this is a set of settings that will be skipped if the user chooses to reset. self._skip_reset_setting_set = set() diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py index 8f2164261b..09ace28d37 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py @@ -1,5 +1,6 @@ -# Copyright (c) 2016 Ultimaker B.V. -# Uranium is released under the terms of the LGPLv3 or higher. +# Copyright (c) 2020 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. + from UM.Logger import Logger from UM.Tool import Tool from UM.Scene.Selection import Selection @@ -22,14 +23,13 @@ class PerObjectSettingsTool(Tool): self._multi_extrusion = False self._single_model_selected = False + self.visibility_handler = None Selection.selectionChanged.connect(self.propertyChanged) - Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged) self._onGlobalContainerChanged() Selection.selectionChanged.connect(self._updateEnabled) - def event(self, event): super().event(event) if event.type == Event.MousePressEvent and self._controller.getToolsEnabled(): @@ -103,6 +103,9 @@ class PerObjectSettingsTool(Tool): new_instance.setProperty("value", 0) new_instance.resetState() # Ensure that the state is not seen as a user state. settings.addInstance(new_instance) + visible = self.visibility_handler.getVisible() + visible.add(property_key) + self.visibility_handler.setVisible(visible) elif old_mesh_type == "infill_mesh" and settings.getInstance(property_key) and settings.getProperty(property_key, "value") == 0: settings.removeInstance(property_key) From a776f54e7f3ad626943b05340309cd7445352c7d Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 13 Feb 2020 13:09:57 +0100 Subject: [PATCH 3/3] Fix making settings visible if the default was 0 If the default was 0, then the if statement would evaluate as False and it would not make them visible until you closed and re-opened the panel. Contributes to issue CURA-7211. --- .../PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py b/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py index fb78134833..ea64ddbb35 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py +++ b/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py @@ -71,7 +71,7 @@ class PerObjectSettingVisibilityHandler(UM.Settings.Models.SettingVisibilityHand # Add all instances that are not added, but are in visibility list for item in visible: - if not settings.getInstance(item): # Setting was not added already. + if settings.getInstance(item) is not None: # Setting was not added already. definition = self._stack.getSettingDefinition(item) if definition: new_instance = SettingInstance(definition, settings)