From 55dd08eff81cd5e20b5f07c9590dc6679f326d67 Mon Sep 17 00:00:00 2001 From: Jack Ha Date: Tue, 3 Jan 2017 09:18:26 +0100 Subject: [PATCH] Somewhat better layout, added legend --- .../ProcessSlicedLayersJob.py | 8 +-- plugins/LayerView/LayerView.qml | 57 +++++++++++++++++++ plugins/LayerView/LayerViewProxy.py | 7 +++ 3 files changed, 67 insertions(+), 5 deletions(-) diff --git a/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py b/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py index 028c51b3ed..49c306ea77 100644 --- a/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py +++ b/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py @@ -16,6 +16,7 @@ from UM.Logger import Logger from UM.Math.Vector import Vector +from cura.Settings.ExtruderManager import ExtruderManager from cura import LayerDataBuilder from cura import LayerDataDecorator from cura import LayerPolygon @@ -159,11 +160,7 @@ class ProcessSlicedLayersJob(Job): # We are done processing all the layers we got from the engine, now create a mesh out of the data # Find out colors per extruder - # TODO: move to a better place. Code is similar to code in ExtrudersModel - from cura.Settings.ExtruderManager import ExtruderManager - import UM - - global_container_stack = UM.Application.getInstance().getGlobalContainerStack() + global_container_stack = Application.getInstance().getGlobalContainerStack() manager = ExtruderManager.getInstance() extruders = list(manager.getMachineExtruders(global_container_stack.getId())) if extruders: @@ -182,6 +179,7 @@ class ProcessSlicedLayersJob(Job): color = colorCodeToRGBA(color_code) material_color_map[0, :] = color + # We have to scale the colors for compatibility mode if bool(Preferences.getInstance().getValue("view/compatibility_mode")): line_type_brightness = 0.5 else: diff --git a/plugins/LayerView/LayerView.qml b/plugins/LayerView/LayerView.qml index 73c34520d6..0e9a2cd7c9 100644 --- a/plugins/LayerView/LayerView.qml +++ b/plugins/LayerView/LayerView.qml @@ -181,8 +181,10 @@ Item } ColumnLayout { + id: view_settings anchors.top: layer_type_combobox.bottom anchors.topMargin: UM.Theme.getSize("default_margin").height + x: UM.Theme.getSize("default_margin").width CheckBox { checked: true @@ -243,5 +245,60 @@ Item } } + // legend + ListView { + + visible: (UM.LayerView.getLayerViewType() == 1) // line type + anchors.top: view_settings.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + //width: parent.width + //height: childrenRect.height + + delegate: Row + { + Rectangle + { + id: rect + + x: UM.Theme.getSize("default_margin").width + y: index * UM.Theme.getSize("section_icon").height + + //width: UM.Theme.getSize("section_icon").width + //height: 0.5 * UM.Theme.getSize("section_icon").height + width: UM.Theme.getSize("setting_control").height / 2 + height: UM.Theme.getSize("setting_control").height / 2 + //Behavior on height { NumberAnimation { duration: 50; } } + + border.width: UM.Theme.getSize("default_lining").width; + border.color: UM.Theme.getColor("slider_groove_border"); + + color: model.color; + } + + Label + { + anchors.left: rect.right + anchors.verticalCenter: rect.verticalCenter + anchors.leftMargin: UM.Theme.getSize("default_margin").width + text: model.label + } + } + model: ListModel + { + id: legendModel + } + Component.onCompleted: + { + // see LayerPolygon + legendModel.append({ label:catalog.i18nc("@label", "Inset0"), color: "#ff0000" }); + legendModel.append({ label:catalog.i18nc("@label", "InsetX"), color: "#00ff00" }); + legendModel.append({ label:catalog.i18nc("@label", "Skin"), color: "#ffff00" }); + legendModel.append({ label:catalog.i18nc("@label", "Support, Skirt, SupportInfill"), color: "#00ffff" }); + legendModel.append({ label:catalog.i18nc("@label", "Infill"), color: "#ffbf00" }); + legendModel.append({ label:catalog.i18nc("@label", "MoveCombing"), color: "#0000ff" }); + legendModel.append({ label:catalog.i18nc("@label", "MoveRetraction"), color: "#8080ff" }); + legendModel.append({ label:catalog.i18nc("@label", "SupportInterface"), color: "#3fbfff" }); + } + } } } diff --git a/plugins/LayerView/LayerViewProxy.py b/plugins/LayerView/LayerViewProxy.py index 8b9a9b7d38..4cf1668ca3 100644 --- a/plugins/LayerView/LayerViewProxy.py +++ b/plugins/LayerView/LayerViewProxy.py @@ -76,6 +76,13 @@ class LayerViewProxy(QObject): if type(active_view) == LayerView.LayerView.LayerView: active_view.setLayerViewType(layer_view_type) + @pyqtProperty(bool) + def getLayerViewType(self): + active_view = self._controller.getActiveView() + if type(active_view) == LayerView.LayerView.LayerView: + return active_view.getLayerViewType() + return 0 + @pyqtSlot(bool) def setOnlyColorActiveExtruder(self, only_color_active_extruder): active_view = self._controller.getActiveView()