From 3666b35ff3f0a8ddeb7b6b23f4814508a86493f9 Mon Sep 17 00:00:00 2001 From: Ruben D Date: Wed, 13 Dec 2017 01:41:36 +0100 Subject: [PATCH 1/7] Fix winding order of 3D tubes Adding a copy of the first vertex causes the winding order to reverse. --- plugins/SimulationView/layers3d.shader | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/SimulationView/layers3d.shader b/plugins/SimulationView/layers3d.shader index 2633b54787..14a766f764 100644 --- a/plugins/SimulationView/layers3d.shader +++ b/plugins/SimulationView/layers3d.shader @@ -192,6 +192,7 @@ geometry41core = } else { // All normal lines are rendered as 3d tubes. myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz)); + myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_vert)); From 79d7de050e86128b6b140508eef79df66051f4d4 Mon Sep 17 00:00:00 2001 From: Ruben D Date: Wed, 13 Dec 2017 01:42:24 +0100 Subject: [PATCH 2/7] Enable backface culling for layer view This effectively doubles the rendering performance of layer view. --- plugins/SimulationView/SimulationPass.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/SimulationView/SimulationPass.py b/plugins/SimulationView/SimulationPass.py index 46fa7f1240..24bdedd368 100644 --- a/plugins/SimulationView/SimulationPass.py +++ b/plugins/SimulationView/SimulationPass.py @@ -92,7 +92,7 @@ class SimulationPass(RenderPass): self.bind() - tool_handle_batch = RenderBatch(self._tool_handle_shader, type = RenderBatch.RenderType.Overlay) + tool_handle_batch = RenderBatch(self._tool_handle_shader, type = RenderBatch.RenderType.Overlay, backface_cull = True) head_position = None # Indicates the current position of the print head nozzle_node = None @@ -149,7 +149,7 @@ class SimulationPass(RenderPass): self._current_shader = self._layer_shader self._switching_layers = True - layers_batch = RenderBatch(self._current_shader, type = RenderBatch.RenderType.Solid, mode = RenderBatch.RenderMode.Lines, range = (start, end)) + layers_batch = RenderBatch(self._current_shader, type = RenderBatch.RenderType.Solid, mode = RenderBatch.RenderMode.Lines, range = (start, end), backface_cull = True) layers_batch.addItem(node.getWorldTransformation(), layer_data) layers_batch.render(self._scene.getActiveCamera()) From e36099a3807f62ed1a811dd637a5313e149fa792 Mon Sep 17 00:00:00 2001 From: Ruben D Date: Wed, 13 Dec 2017 01:44:05 +0100 Subject: [PATCH 3/7] Draw backside of travel lines inverted This adds a front-facing primitive towards the back side of every travel line, causing those lines to be visible from both sides regardless of backface culling. This doubles the number of vertices for travel moves, but due to backface culling it comes down to approximately the same performance as the original. --- plugins/SimulationView/layers3d.shader | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/SimulationView/layers3d.shader b/plugins/SimulationView/layers3d.shader index 14a766f764..cbd27a2660 100644 --- a/plugins/SimulationView/layers3d.shader +++ b/plugins/SimulationView/layers3d.shader @@ -187,6 +187,13 @@ geometry41core = myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head + g_vertex_offset_vert)); + //And reverse so that the line is also visible from the back side. + myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); + myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert)); + myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); + myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert)); + myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head + g_vertex_offset_vert)); + myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); EndPrimitive(); } else { From f69375691f0e7933e897e34c4535fe4fcb07a22b Mon Sep 17 00:00:00 2001 From: Ruben D Date: Wed, 13 Dec 2017 18:58:05 +0100 Subject: [PATCH 4/7] Reduce vertices per tube by 1 Since the tubes are symmetrical, instead of using an extra vertex to flip the winding order, I just mirror all horizontal coordinates so that the triangles flip inside out. --- plugins/SimulationView/layers3d.shader | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/SimulationView/layers3d.shader b/plugins/SimulationView/layers3d.shader index cbd27a2660..86a88fab83 100644 --- a/plugins/SimulationView/layers3d.shader +++ b/plugins/SimulationView/layers3d.shader @@ -198,17 +198,16 @@ geometry41core = EndPrimitive(); } else { // All normal lines are rendered as 3d tubes. - myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz)); - myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz)); - myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz)); - myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_vert)); - myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz)); - myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_vert)); - myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_vert)); + myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_vert)); + myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz)); + myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_vert)); + myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_vert)); + myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz)); + myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz)); EndPrimitive(); From cda6aa25477107bab996db8bb37cf271f1342d4e Mon Sep 17 00:00:00 2001 From: Jack Ha Date: Thu, 14 Dec 2017 14:49:18 +0100 Subject: [PATCH 5/7] CURA-4234 splitted MachineSelection into a separate file and add it to PrintMonitor as well, because now it's part of the sidebar --- resources/qml/MachineSelection.qml | 71 ++++++++++++++++++++++++++++++ resources/qml/PrintMonitor.qml | 10 ++++- resources/qml/Sidebar.qml | 60 +------------------------ 3 files changed, 81 insertions(+), 60 deletions(-) create mode 100644 resources/qml/MachineSelection.qml diff --git a/resources/qml/MachineSelection.qml b/resources/qml/MachineSelection.qml new file mode 100644 index 0000000000..e40731f3ca --- /dev/null +++ b/resources/qml/MachineSelection.qml @@ -0,0 +1,71 @@ +// Copyright (c) 2017 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 +import QtQuick.Layouts 1.1 + +import UM 1.2 as UM +import Cura 1.0 as Cura +import "Menus" + +ToolButton +{ + text: Cura.MachineManager.activeMachineName + + tooltip: Cura.MachineManager.activeMachineName + + style: ButtonStyle + { + background: Rectangle + { + color: + { + if(control.pressed) + { + return UM.Theme.getColor("sidebar_header_active"); + } + else if(control.hovered) + { + return UM.Theme.getColor("sidebar_header_hover"); + } + else + { + return UM.Theme.getColor("sidebar_header_bar"); + } + } + Behavior on color { ColorAnimation { duration: 50; } } + + UM.RecolorImage + { + id: downArrow + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + width: UM.Theme.getSize("standard_arrow").width + height: UM.Theme.getSize("standard_arrow").height + sourceSize.width: width + sourceSize.height: width + color: UM.Theme.getColor("text_emphasis") + source: UM.Theme.getIcon("arrow_bottom") + } + Label + { + id: sidebarComboBoxLabel + color: UM.Theme.getColor("sidebar_header_text_active") + text: control.text; + elide: Text.ElideRight; + anchors.left: parent.left; + anchors.leftMargin: UM.Theme.getSize("default_margin").width * 2 + anchors.right: downArrow.left; + anchors.rightMargin: control.rightMargin; + anchors.verticalCenter: parent.verticalCenter; + font: UM.Theme.getFont("large") + } + } + label: Label {} + } + + menu: PrinterMenu { } +} diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index e69f7cf4fd..806e302047 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -20,6 +20,14 @@ Column simpleNames: true } + MachineSelection { + id: machineSelection + width: base.width + height: UM.Theme.getSize("sidebar_header").height + anchors.top: base.top + anchors.right: parent.right + } + Rectangle { id: connectedPrinterHeader @@ -1171,4 +1179,4 @@ Column } } } -} \ No newline at end of file +} diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index a45303aab8..66c23752ce 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -87,70 +87,12 @@ Rectangle } } - ToolButton - { + MachineSelection { id: machineSelection - text: Cura.MachineManager.activeMachineName - width: base.width height: UM.Theme.getSize("sidebar_header").height - tooltip: Cura.MachineManager.activeMachineName - anchors.top: base.top - //anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right - style: ButtonStyle - { - background: Rectangle - { - color: - { - if(control.pressed) - { - return UM.Theme.getColor("sidebar_header_active"); - } - else if(control.hovered) - { - return UM.Theme.getColor("sidebar_header_hover"); - } - else - { - return UM.Theme.getColor("sidebar_header_bar"); - } - } - Behavior on color { ColorAnimation { duration: 50; } } - - UM.RecolorImage - { - id: downArrow - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width - width: UM.Theme.getSize("standard_arrow").width - height: UM.Theme.getSize("standard_arrow").height - sourceSize.width: width - sourceSize.height: width - color: UM.Theme.getColor("text_emphasis") - source: UM.Theme.getIcon("arrow_bottom") - } - Label - { - id: sidebarComboBoxLabel - color: UM.Theme.getColor("sidebar_header_text_active") - text: control.text; - elide: Text.ElideRight; - anchors.left: parent.left; - anchors.leftMargin: UM.Theme.getSize("default_margin").width * 2 - anchors.right: downArrow.left; - anchors.rightMargin: control.rightMargin; - anchors.verticalCenter: parent.verticalCenter; - font: UM.Theme.getFont("large") - } - } - label: Label {} - } - - menu: PrinterMenu { } } SidebarHeader { From c056fcb23d3d9a7530cf9a21bbf0a83e63660908 Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Thu, 14 Dec 2017 14:58:51 +0100 Subject: [PATCH 6/7] Fix monitor sidebar machine selection - CURA-4234 --- resources/qml/PrintMonitor.qml | 8 -------- resources/qml/Sidebar.qml | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 806e302047..5a5c160b51 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -20,14 +20,6 @@ Column simpleNames: true } - MachineSelection { - id: machineSelection - width: base.width - height: UM.Theme.getSize("sidebar_header").height - anchors.top: base.top - anchors.right: parent.right - } - Rectangle { id: connectedPrinterHeader diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index 66c23752ce..d5cffb30a6 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -272,7 +272,7 @@ Rectangle { id: controlItem anchors.bottom: footerSeparator.top - anchors.top: monitoringPrint ? base.top : headerSeparator.bottom + anchors.top: monitoringPrint ? machineSelection.bottom : headerSeparator.bottom anchors.left: base.left anchors.right: base.right sourceComponent: @@ -291,7 +291,7 @@ Rectangle Loader { anchors.bottom: footerSeparator.top - anchors.top: monitoringPrint ? base.top : headerSeparator.bottom + anchors.top: monitoringPrint ? machineSelection.bottom : headerSeparator.bottom anchors.left: base.left anchors.right: base.right source: From 47e5303a893dd5b1879a9ecd4f762278807961fd Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Thu, 14 Dec 2017 15:16:17 +0100 Subject: [PATCH 7/7] Catch situations where backend is not correctly set --- resources/qml/SaveButton.qml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/resources/qml/SaveButton.qml b/resources/qml/SaveButton.qml index d53b43e459..9ecde4d72a 100644 --- a/resources/qml/SaveButton.qml +++ b/resources/qml/SaveButton.qml @@ -14,7 +14,7 @@ Item { property real progress: UM.Backend.progress property int backendState: UM.Backend.state - property var backend: CuraApplication.getBackend() + property var backend: CuraApplication.getBackend() || "undefined" property bool activity: CuraApplication.platformActivity property alias buttonRowWidth: saveRow.width @@ -49,12 +49,16 @@ Item { } function sliceOrStopSlicing() { - if (base.backendState != "undefined" && backend !== "undefined") { - if ([1, 5].indexOf(base.backendState) != -1) { - backend.forceSlice(); - } else { - backend.stopSlicing(); + try { + if (base.backendState != "undefined" && base.backend != "undefined") { + if ([1, 5].indexOf(base.backendState) != -1) { + backend.forceSlice(); + } else { + backend.stopSlicing(); + } } + } catch (e) { + console.log('Could not start or stop slicing', e) } }