From ff14db91334b823d28c24c3fd92c1c994918669a Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 9 Nov 2017 11:29:50 +0100 Subject: [PATCH 01/13] Remove convex hull for meshes that don't print geometry Anti-overhang, Infill and Cutting meshes don't print geometry, so they don't need to push other objects away. --- cura/ConvexHullDecorator.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cura/ConvexHullDecorator.py b/cura/ConvexHullDecorator.py index bfeb690192..4a2c365437 100644 --- a/cura/ConvexHullDecorator.py +++ b/cura/ConvexHullDecorator.py @@ -14,6 +14,13 @@ import numpy ## The convex hull decorator is a scene node decorator that adds the convex hull functionality to a scene node. # If a scene node has a convex hull decorator, it will have a shadow in which other objects can not be printed. class ConvexHullDecorator(SceneNodeDecorator): + ## Meshes that don't need a convex hull + # + # If these settings are True for any mesh, the mesh does not need to push other meshes away. + # Note that Support Mesh is not in here because it actually generates + # g-code in the volume of the mesh. + _not_printed_mesh_settings = {"anti_overhang_mesh", "infill_mesh", "cutting_mesh"} + def __init__(self): super().__init__() @@ -56,6 +63,9 @@ class ConvexHullDecorator(SceneNodeDecorator): if self._node is None: return None + if (self._node.callDecoration("getStack") and any(self._node.callDecoration("getStack").getProperty(setting, "value") for setting in self._not_printed_mesh_settings)): + return None + hull = self._compute2DConvexHull() if self._global_stack and self._node: From 0b11117d6d15cbbfa750d5dfb40e37d31e65e5c0 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 9 Nov 2017 12:28:55 +0100 Subject: [PATCH 02/13] Set a property for non-printing-meshes Remove code duplication --- cura/ConvexHullDecorator.py | 11 +++-------- cura/Settings/SettingOverrideDecorator.py | 10 ++++++++++ plugins/CuraEngineBackend/StartSliceJob.py | 11 +---------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/cura/ConvexHullDecorator.py b/cura/ConvexHullDecorator.py index 4a2c365437..8badc7a825 100644 --- a/cura/ConvexHullDecorator.py +++ b/cura/ConvexHullDecorator.py @@ -14,13 +14,6 @@ import numpy ## The convex hull decorator is a scene node decorator that adds the convex hull functionality to a scene node. # If a scene node has a convex hull decorator, it will have a shadow in which other objects can not be printed. class ConvexHullDecorator(SceneNodeDecorator): - ## Meshes that don't need a convex hull - # - # If these settings are True for any mesh, the mesh does not need to push other meshes away. - # Note that Support Mesh is not in here because it actually generates - # g-code in the volume of the mesh. - _not_printed_mesh_settings = {"anti_overhang_mesh", "infill_mesh", "cutting_mesh"} - def __init__(self): super().__init__() @@ -63,7 +56,9 @@ class ConvexHullDecorator(SceneNodeDecorator): if self._node is None: return None - if (self._node.callDecoration("getStack") and any(self._node.callDecoration("getStack").getProperty(setting, "value") for setting in self._not_printed_mesh_settings)): + if getattr(self._node, "_non_printing_mesh", False): + # infill_mesh, cutting_mesh and anti_overhang_mesh do not need a convex hull + # node._non_printing_mesh is set in SettingOverrideDecorator return None hull = self._compute2DConvexHull() diff --git a/cura/Settings/SettingOverrideDecorator.py b/cura/Settings/SettingOverrideDecorator.py index 4e0893a35f..63e2a6837f 100644 --- a/cura/Settings/SettingOverrideDecorator.py +++ b/cura/Settings/SettingOverrideDecorator.py @@ -22,6 +22,14 @@ class SettingOverrideDecorator(SceneNodeDecorator): ## Event indicating that the user selected a different extruder. activeExtruderChanged = Signal() + ## Non-printing meshes + # + # If these settings are True for any mesh, the mesh does not need a convex hull, + # and is sent to the slicer regardless of whether it fits inside the build volume. + # Note that Support Mesh is not in here because it actually generates + # g-code in the volume of the mesh. + _non_printing_mesh_settings = {"anti_overhang_mesh", "infill_mesh", "cutting_mesh"} + def __init__(self): super().__init__() self._stack = PerObjectContainerStack(stack_id = id(self)) @@ -82,6 +90,8 @@ class SettingOverrideDecorator(SceneNodeDecorator): Application.getInstance().getBackend().needsSlicing() Application.getInstance().getBackend().tickle() + self._node._non_printing_mesh = any(self._stack.getProperty(setting, "value") for setting in self._non_printing_mesh_settings) + ## Makes sure that the stack upon which the container stack is placed is # kept up to date. def _updateNextStack(self): diff --git a/plugins/CuraEngineBackend/StartSliceJob.py b/plugins/CuraEngineBackend/StartSliceJob.py index a53daa4e63..ca84f554a4 100644 --- a/plugins/CuraEngineBackend/StartSliceJob.py +++ b/plugins/CuraEngineBackend/StartSliceJob.py @@ -44,14 +44,6 @@ class GcodeStartEndFormatter(Formatter): ## Job class that builds up the message of scene data to send to CuraEngine. class StartSliceJob(Job): - ## Meshes that are sent to the engine regardless of being outside of the - # build volume. - # - # If these settings are True for any mesh, the build volume is ignored. - # Note that Support Mesh is not in here because it actually generates - # g-code in the volume of the mesh. - _not_printed_mesh_settings = {"anti_overhang_mesh", "infill_mesh", "cutting_mesh"} - def __init__(self, slice_message): super().__init__() @@ -140,8 +132,7 @@ class StartSliceJob(Job): temp_list = [] for node in DepthFirstIterator(self._scene.getRoot()): if type(node) is SceneNode and node.getMeshData() and node.getMeshData().getVertices() is not None: - if not getattr(node, "_outside_buildarea", False)\ - or (node.callDecoration("getStack") and any(node.callDecoration("getStack").getProperty(setting, "value") for setting in self._not_printed_mesh_settings)): + if not getattr(node, "_outside_buildarea", False) or getattr(node, "_non_printing_mesh", False): temp_list.append(node) Job.yieldThread() From 8f8bdc059ab9f8065a2b1ec6b75b60608bfffb23 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 9 Nov 2017 12:55:03 +0100 Subject: [PATCH 03/13] Render non-printing objects as semi transparent objects in Solid View --- plugins/SolidView/SolidView.py | 29 ++++++++++++++++---------- resources/themes/cura-light/theme.json | 1 + 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 8f0c9a4dc1..3474fa88f2 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -27,25 +27,33 @@ class SolidView(View): self._enabled_shader = None self._disabled_shader = None + self._non_printing_shader = None self._extruders_model = ExtrudersModel() + self._theme = None def beginRendering(self): scene = self.getController().getScene() renderer = self.getRenderer() + if not self._theme: + self._theme = Application.getInstance().getTheme() + if not self._enabled_shader: self._enabled_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "overhang.shader")) - theme = Application.getInstance().getTheme() - self._enabled_shader.setUniformValue("u_overhangColor", Color(*theme.getColor("model_overhang").getRgb())) + self._enabled_shader.setUniformValue("u_overhangColor", Color(*self._theme.getColor("model_overhang").getRgb())) if not self._disabled_shader: self._disabled_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "striped.shader")) - theme = Application.getInstance().getTheme() - self._disabled_shader.setUniformValue("u_diffuseColor1", Color(*theme.getColor("model_unslicable").getRgb())) - self._disabled_shader.setUniformValue("u_diffuseColor2", Color(*theme.getColor("model_unslicable_alt").getRgb())) + self._disabled_shader.setUniformValue("u_diffuseColor1", Color(*self._theme.getColor("model_unslicable").getRgb())) + self._disabled_shader.setUniformValue("u_diffuseColor2", Color(*self._theme.getColor("model_unslicable_alt").getRgb())) self._disabled_shader.setUniformValue("u_width", 50.0) + if not self._non_printing_shader: + self._non_printing_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "transparent_object.shader")) + self._non_printing_shader.setUniformValue("u_diffuseColor", Color(*self._theme.getColor("model_non_printing").getRgb())) + self._non_printing_shader.setUniformValue("u_opacity", 0.6) + multi_extrusion = False global_container_stack = Application.getInstance().getGlobalContainerStack() @@ -110,13 +118,12 @@ class SolidView(View): except ValueError: pass - if hasattr(node, "_outside_buildarea"): - if node._outside_buildarea: - renderer.queueNode(node, shader = self._disabled_shader) - else: - renderer.queueNode(node, shader = self._enabled_shader, uniforms = uniforms) + if getattr(node, "_non_printing_mesh", False): + renderer.queueNode(node, shader = self._non_printing_shader, transparent = True) + elif getattr(node, "_outside_buildarea", False): + renderer.queueNode(node, shader = self._disabled_shader) else: - renderer.queueNode(node, material = self._enabled_shader, uniforms = uniforms) + renderer.queueNode(node, shader = self._enabled_shader, uniforms = uniforms) if node.callDecoration("isGroup") and Selection.isSelected(node): renderer.queueNode(scene.getRoot(), mesh = node.getBoundingBoxMesh(), mode = RenderBatch.RenderMode.LineLoop) diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 50ee600e4e..6d07ca09b8 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -256,6 +256,7 @@ "model_unslicable": [122, 122, 122, 255], "model_unslicable_alt": [172, 172, 127, 255], "model_selection_outline": [12, 169, 227, 255], + "model_non_printing": [122, 122, 122, 255], "xray": [26, 26, 62, 255], "xray_error": [255, 0, 0, 255], From 3251e5915be2effbb558379539fd1b7992396c8b Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 9 Nov 2017 16:04:13 +0100 Subject: [PATCH 04/13] Show the support material for support_mesh --- plugins/SolidView/SolidView.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 3474fa88f2..56d8cf11d7 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -98,12 +98,19 @@ class SolidView(View): extruder_id = node.callDecoration("getActiveExtruder") if extruder_id: extruder_index = max(0, self._extruders_model.find("id", extruder_id)) + + # Use the support extruder instead of the active extruder if this is a support_mesh + per_mesh_stack = node.callDecoration("getStack") + if per_mesh_stack: + if per_mesh_stack.getProperty("support_mesh", "value"): + extruder_index = global_container_stack.getProperty("support_extruder_nr", "value") + try: material_color = self._extruders_model.getItem(extruder_index)["color"] except KeyError: material_color = self._extruders_model.defaultColors[0] - if extruder_index != ExtruderManager.getInstance().activeExtruderIndex: + if int(extruder_index) != int(ExtruderManager.getInstance().activeExtruderIndex): # Shade objects that are printed with the non-active extruder 25% darker shade_factor = 0.6 try: From 7bf40ef82b436d5621a2b60c461e7bd17174704a Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 9 Nov 2017 17:15:56 +0100 Subject: [PATCH 05/13] Add dropdown to per object settings for quick access to mesh types (not yet functional) --- .../PerObjectSettingsPanel.qml | 71 ++++++++++++++----- 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index c15431c9e2..57b98b3161 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -26,17 +26,62 @@ Item { spacing: UM.Theme.getSize("default_margin").height + Row + { + spacing: UM.Theme.getSize("default_margin").width + + Label + { + text: catalog.i18nc("@label","Mesh Type") + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("text") + height: UM.Theme.getSize("setting").height + verticalAlignment: Text.AlignVCenter + } + + ComboBox + { + id: meshTypeSelection + style: UM.Theme.styles.combobox + model: ListModel + { + id: meshTypeModel + Component.onCompleted: + { + meshTypeModel.append({ + type: "", + text: catalog.i18nc("@label", "Normal model") + }); + meshTypeModel.append({ + type: "support_mesh", + text: catalog.i18nc("@label", "Print as support") + }); + meshTypeModel.append({ + type: "anti_overhang_mesh", + text: catalog.i18nc("@label", "Remove support for overlap with other models") + }); + meshTypeModel.append({ + type: "cutting_mesh", + text: catalog.i18nc("@label", "Modify extruder or settings for overlap with other models") + }); + } + } + } + } + Column { // This is to ensure that the panel is first increasing in size up to 200 and then shows a scrollbar. // It kinda looks ugly otherwise (big panel, no content on it) + id: currentSettings property int maximumHeight: 200 * screenScaleFactor height: Math.min(contents.count * (UM.Theme.getSize("section").height + UM.Theme.getSize("default_lining").height), maximumHeight) + visible: ["support_mesh", "anti_overhang_mesh"].indexOf(meshTypeSelection.model.get(meshTypeSelection.currentIndex).type) == -1 ScrollView { height: parent.height - width: UM.Theme.getSize("setting").width + UM.Theme.getSize("setting").height + width: UM.Theme.getSize("setting").width style: UM.Theme.styles.scrollview ListView @@ -58,6 +103,7 @@ Item { delegate: Row { + spacing: - UM.Theme.getSize("default_margin").width Loader { id: settingLoader @@ -112,7 +158,7 @@ Item { Button { - width: (UM.Theme.getSize("setting").height / 2) | 0 + width: Math.floor(UM.Theme.getSize("setting").height / 2) height: UM.Theme.getSize("setting").height onClicked: addedSettingsModel.setVisible(model.key, false) @@ -125,7 +171,7 @@ Item { { anchors.verticalCenter: parent.verticalCenter width: parent.width - height: parent.height / 2 + height: width sourceSize.width: width sourceSize.height: width color: control.hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button") @@ -201,9 +247,9 @@ Item { Button { - id: customise_settings_button; - height: UM.Theme.getSize("setting").height; - visible: parseInt(UM.Preferences.getValue("cura/active_mode")) == 1 + id: customiseSettingsButton; + height: UM.Theme.getSize("setting_control").height; + visible: currentSettings.visible text: catalog.i18nc("@action:button", "Select settings"); @@ -223,21 +269,12 @@ Item { { text: control.text; color: UM.Theme.getColor("setting_control_text"); + font: UM.Theme.getFont("default") anchors.centerIn: parent } } onClicked: settingPickDialog.visible = true; - - Connections - { - target: UM.Preferences; - - onPreferenceChanged: - { - customise_settings_button.visible = parseInt(UM.Preferences.getValue("cura/active_mode")) - } - } } } @@ -325,7 +362,7 @@ Item { } visibilityHandler: UM.SettingPreferenceVisibilityHandler {} expanded: [ "*" ] - exclude: [ "machine_settings", "command_line_settings" ] + exclude: [ "machine_settings", "command_line_settings", "support_mesh", "anti_overhang_mesh", "cutting_mesh", "infill_mesh" ] } delegate:Loader { From 316ae49b0bf565d4d13d3811c623774c7674eeec Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 9 Nov 2017 18:25:09 +0100 Subject: [PATCH 06/13] Fix setting mesh type through Per Model Settings combobox --- .../PerObjectSettingsPanel.qml | 4 ++++ .../PerObjectSettingsTool.py | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index 57b98b3161..138749c1bf 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -43,6 +43,9 @@ Item { { id: meshTypeSelection style: UM.Theme.styles.combobox + onActivated: { + UM.ActiveTool.setProperty("MeshType", model.get(index).type) + } model: ListModel { id: meshTypeModel @@ -94,6 +97,7 @@ Item { id: addedSettingsModel; containerId: Cura.MachineManager.activeDefinitionId expanded: [ "*" ] + exclude: [ "support_mesh", "anti_overhang_mesh", "cutting_mesh", "infill_mesh" ] visibilityHandler: Cura.PerObjectSettingVisibilityHandler { diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py index d0cb53c4f8..119c8db41d 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py @@ -8,6 +8,7 @@ from UM.Application import Application from UM.Preferences import Preferences from cura.Settings.SettingOverrideDecorator import SettingOverrideDecorator from cura.Settings.ExtruderManager import ExtruderManager +from UM.Settings.SettingInstance import SettingInstance from UM.Event import Event @@ -70,6 +71,26 @@ class PerObjectSettingsTool(Tool): selected_object.addDecorator(SettingOverrideDecorator()) selected_object.callDecoration("setActiveExtruder", extruder_stack_id) + def setMeshType(self, mesh_type): + selected_object = Selection.getSelectedObject(0) + stack = selected_object.callDecoration("getStack") #Don't try to get the active extruder since it may be None anyway. + if not stack: + selected_object.addDecorator(SettingOverrideDecorator()) + stack = selected_object.callDecoration("getStack") + + settings = stack.getTop() + for property_key in ["infill_mesh", "cutting_mesh", "support_mesh", "anti_overhang_mesh"]: + if property_key != mesh_type: + if settings.getInstance(property_key): + settings.removeInstance(property_key) + else: + if not (settings.getInstance(property_key) and settings.getProperty(property_key, "value")): + definition = stack.getSettingDefinition(property_key) + new_instance = SettingInstance(definition, settings) + new_instance.setProperty("value", True) + new_instance.resetState() # Ensure that the state is not seen as a user state. + settings.addInstance(new_instance) + def _onPreferenceChanged(self, preference): if preference == "cura/active_mode": self._advanced_mode = Preferences.getInstance().getValue(preference) == 1 From 9c3e50c494de2bbe7c97562774fa16e339c46bd5 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 9 Nov 2017 19:21:05 +0100 Subject: [PATCH 07/13] Ignore models without a convex hull when auto arranging --- cura/Arrange.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cura/Arrange.py b/cura/Arrange.py index 0d1f2e0c06..335e42a267 100755 --- a/cura/Arrange.py +++ b/cura/Arrange.py @@ -52,6 +52,8 @@ class Arrange: # Place all objects fixed nodes for fixed_node in fixed_nodes: vertices = fixed_node.callDecoration("getConvexHull") + if not vertices: + continue points = copy.deepcopy(vertices._points) shape_arr = ShapeArray.fromPolygon(points, scale = scale) arranger.place(0, 0, shape_arr) From a1320939e833f9bf7024b9e52495a642b54759cc Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 9 Nov 2017 21:42:10 +0100 Subject: [PATCH 08/13] Update mesh type dropdown when to reflect the selected object --- .../PerObjectSettingsPanel.qml | 23 +++++++++++++++++++ .../PerObjectSettingsTool.py | 15 +++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index 138749c1bf..de396b1570 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -67,9 +67,32 @@ Item { type: "cutting_mesh", text: catalog.i18nc("@label", "Modify extruder or settings for overlap with other models") }); + + meshTypeSelection.updateCurrentIndex(); } } + + function updateCurrentIndex() + { + var mesh_type = UM.ActiveTool.properties.getValue("MeshType"); + for(var index=0; index < meshTypeSelection.model.count; index++) + { + if(meshTypeSelection.model.get(index).type == mesh_type) + { + meshTypeSelection.currentIndex = index; + return; + } + } + meshTypeSelection.currentIndex = 0; + } } + + Connections + { + target: UM.Selection + onSelectionChanged: meshTypeSelection.updateCurrentIndex() + } + } Column diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py index 119c8db41d..f0fc0f7cb5 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py @@ -19,7 +19,7 @@ class PerObjectSettingsTool(Tool): super().__init__() self._model = None - self.setExposedProperties("SelectedObjectId", "ContainerID", "SelectedActiveExtruder") + self.setExposedProperties("SelectedObjectId", "ContainerID", "SelectedActiveExtruder", "MeshType") self._advanced_mode = False self._multi_extrusion = False @@ -91,6 +91,19 @@ class PerObjectSettingsTool(Tool): new_instance.resetState() # Ensure that the state is not seen as a user state. settings.addInstance(new_instance) + def getMeshType(self): + selected_object = Selection.getSelectedObject(0) + stack = selected_object.callDecoration("getStack") #Don't try to get the active extruder since it may be None anyway. + if not stack: + return "" + + settings = stack.getTop() + for property_key in ["infill_mesh", "cutting_mesh", "support_mesh", "anti_overhang_mesh"]: + if settings.getInstance(property_key) and settings.getProperty(property_key, "value"): + return property_key + + return "" + def _onPreferenceChanged(self, preference): if preference == "cura/active_mode": self._advanced_mode = Preferences.getInstance().getValue(preference) == 1 From 69b707cbfe490ccd7cebfb9df907c637a3bd1e09 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 9 Nov 2017 22:02:20 +0100 Subject: [PATCH 09/13] Fix coloring support_mesh with the color of the support_extruder --- plugins/SolidView/SolidView.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 56d8cf11d7..5c8f9c929f 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -103,14 +103,14 @@ class SolidView(View): per_mesh_stack = node.callDecoration("getStack") if per_mesh_stack: if per_mesh_stack.getProperty("support_mesh", "value"): - extruder_index = global_container_stack.getProperty("support_extruder_nr", "value") + extruder_index = int(global_container_stack.getProperty("support_extruder_nr", "value")) try: material_color = self._extruders_model.getItem(extruder_index)["color"] except KeyError: material_color = self._extruders_model.defaultColors[0] - if int(extruder_index) != int(ExtruderManager.getInstance().activeExtruderIndex): + if extruder_index != ExtruderManager.getInstance().activeExtruderIndex: # Shade objects that are printed with the non-active extruder 25% darker shade_factor = 0.6 try: From ac27b3f8115a9f9d6786f13e555445eec6d7b3d2 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Fri, 10 Nov 2017 10:08:27 +0100 Subject: [PATCH 10/13] Add infill_mesh as an option to the dropdown --- plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index de396b1570..e110c01f75 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -65,7 +65,11 @@ Item { }); meshTypeModel.append({ type: "cutting_mesh", - text: catalog.i18nc("@label", "Modify extruder or settings for overlap with other models") + text: catalog.i18nc("@label", "Modify settings for overlap with other models") + }); + meshTypeModel.append({ + type: "infill_mesh", + text: catalog.i18nc("@label", "Modify settings for overlap with infill of other models") }); meshTypeSelection.updateCurrentIndex(); From e00ac591bf21acc8c46a436d809d0321dd272d12 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Fri, 10 Nov 2017 12:24:32 +0100 Subject: [PATCH 11/13] Use material color for cutting_mesh and infill_mesh --- plugins/SolidView/SolidView.py | 8 ++++++-- resources/shaders/transparent_object.shader | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 5c8f9c929f..3fb93c0332 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -86,6 +86,8 @@ class SolidView(View): uniforms = {} shade_factor = 1.0 + per_mesh_stack = node.callDecoration("getStack") + if not multi_extrusion: if global_container_stack: material = global_container_stack.findContainer({ "type": "material" }) @@ -100,7 +102,6 @@ class SolidView(View): extruder_index = max(0, self._extruders_model.find("id", extruder_id)) # Use the support extruder instead of the active extruder if this is a support_mesh - per_mesh_stack = node.callDecoration("getStack") if per_mesh_stack: if per_mesh_stack.getProperty("support_mesh", "value"): extruder_index = int(global_container_stack.getProperty("support_extruder_nr", "value")) @@ -126,7 +127,10 @@ class SolidView(View): pass if getattr(node, "_non_printing_mesh", False): - renderer.queueNode(node, shader = self._non_printing_shader, transparent = True) + if per_mesh_stack and (per_mesh_stack.getProperty("infill_mesh", "value") or per_mesh_stack.getProperty("cutting_mesh", "value")): + renderer.queueNode(node, shader = self._non_printing_shader, uniforms = uniforms, transparent = True) + else: + renderer.queueNode(node, shader = self._non_printing_shader, transparent = True) elif getattr(node, "_outside_buildarea", False): renderer.queueNode(node, shader = self._disabled_shader) else: diff --git a/resources/shaders/transparent_object.shader b/resources/shaders/transparent_object.shader index faa43bb46c..75fe7e4b2c 100644 --- a/resources/shaders/transparent_object.shader +++ b/resources/shaders/transparent_object.shader @@ -111,6 +111,7 @@ u_modelMatrix = model_matrix u_viewProjectionMatrix = view_projection_matrix u_normalMatrix = normal_matrix u_lightPosition = light_0_position +u_diffuseColor = diffuse_color [attributes] a_vertex = vertex From dcdd1f86508495cd676de32eb0f0f06cc718f1bc Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Fri, 10 Nov 2017 12:27:15 +0100 Subject: [PATCH 12/13] Tweak descriptions of mesh type options --- plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index e110c01f75..65b67791c7 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -61,7 +61,7 @@ Item { }); meshTypeModel.append({ type: "anti_overhang_mesh", - text: catalog.i18nc("@label", "Remove support for overlap with other models") + text: catalog.i18nc("@label", "Don't support overlap with other models") }); meshTypeModel.append({ type: "cutting_mesh", @@ -69,7 +69,7 @@ Item { }); meshTypeModel.append({ type: "infill_mesh", - text: catalog.i18nc("@label", "Modify settings for overlap with infill of other models") + text: catalog.i18nc("@label", "Modify settings for infill of other models") }); meshTypeSelection.updateCurrentIndex(); From c7f190bb262df1c97eb21f066df2ff3da0cfacd6 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Sat, 18 Nov 2017 11:30:17 +0100 Subject: [PATCH 13/13] Remove (ancient) commented out code --- plugins/SolidView/SolidView.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 2c9f44a254..73a41bb0ec 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -124,7 +124,3 @@ class SolidView(View): def endRendering(self): pass - - #def _onPreferenceChanged(self, preference): - #if preference == "view/show_overhang": ## Todo: This a printer only setting. Should be removed from Uranium. - #self._enabled_material = None