From 5050124699fa50501916fe7319417e480efd3a94 Mon Sep 17 00:00:00 2001 From: Jack Ha Date: Mon, 6 Nov 2017 14:02:22 +0100 Subject: [PATCH] CURA-4525 wip objects menu --- cura/CuraApplication.py | 4 + plugins/CuraEngineBackend/StartSliceJob.py | 10 ++- plugins/SolidView/SolidView.py | 3 +- resources/qml/Cura.qml | 41 +++++++++- resources/qml/ObjectsList.qml | 88 ++++++++++++++++++++++ resources/themes/cura-light/theme.json | 4 +- 6 files changed, 144 insertions(+), 6 deletions(-) create mode 100644 resources/qml/ObjectsList.qml diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index ff8dfd021a..5111b9b52a 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -292,6 +292,8 @@ class CuraApplication(QtApplication): preferences.addPreference("metadata/setting_version", 0) preferences.setValue("metadata/setting_version", self.SettingVersion) #Don't make it equal to the default so that the setting version always gets written to the file. + preferences.addPreference("view/build_plate_number", 0) + preferences.addPreference("cura/active_mode", "simple") preferences.addPreference("cura/categories_expanded", "") @@ -1462,6 +1464,8 @@ class CuraApplication(QtApplication): def setActiveBuildPlate(self, nr): Logger.log("d", "Select build plate: %s" % nr) self._active_build_plate = nr + Preferences.setValue("view/build_plate_number", self._active_build_plate) + self.activeBuildPlateChanged.emit() @pyqtSlot() diff --git a/plugins/CuraEngineBackend/StartSliceJob.py b/plugins/CuraEngineBackend/StartSliceJob.py index a53daa4e63..607914f5c5 100644 --- a/plugins/CuraEngineBackend/StartSliceJob.py +++ b/plugins/CuraEngineBackend/StartSliceJob.py @@ -140,9 +140,13 @@ 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)): - temp_list.append(node) + + # temp hack to filter on build plate 0 + if (node.callDecoration("getBuildPlateNumber") == 0): + + 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)): + temp_list.append(node) Job.yieldThread() if temp_list: diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 8f0c9a4dc1..625223a097 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -71,10 +71,11 @@ class SolidView(View): else: self._enabled_shader.setUniformValue("u_overhangAngle", math.cos(math.radians(0))) + activeBuildPlateNumber = Preferences.getInstance().getValue("view/build_plate_number") or 0 for node in DepthFirstIterator(scene.getRoot()): if not node.render(renderer): - if node.getMeshData() and node.isVisible(): + if node.getMeshData() and node.isVisible() and (node.callDecoration("getBuildPlateNumber") == activeBuildPlateNumber): uniforms = {} shade_factor = 1.0 diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 2fd19a8a03..03d0ce9ecd 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -340,6 +340,22 @@ UM.MainWindow action: Cura.Actions.open; } + Button + { + id: objectsButton; + text: catalog.i18nc("@action:button","Objects"); + iconSource: UM.Theme.getIcon("load") + style: UM.Theme.styles.tool_button + tooltip: ''; + anchors + { + top: openFileButton.bottom; + topMargin: UM.Theme.getSize("default_margin").height; + left: parent.left; + } + action: triggerObjectsList; + } + Toolbar { id: toolbar; @@ -348,7 +364,7 @@ UM.MainWindow property int mouseY: base.mouseY anchors { - top: openFileButton.bottom; + top: objectsButton.bottom; topMargin: UM.Theme.getSize("window_margin").height; left: parent.left; } @@ -380,6 +396,29 @@ UM.MainWindow monitoringPrint: base.showPrintMonitor } + Action + { + id: triggerObjectsList; + text: catalog.i18nc("@action:inmenu menubar:file","&Open File(s)..."); + iconName: "document-open"; + shortcut: StandardKey.Open; + onTriggered: objectsList.visible = !objectsList.visible; + } + + ObjectsList + { + id: objectsList; + visible: false; + anchors + { + top: objectsButton.top; + left: objectsButton.right; + leftMargin: UM.Theme.getSize("default_margin").width; + rightMargin: UM.Theme.getSize("default_margin").width; + } + + } + Rectangle { id: viewportOverlay diff --git a/resources/qml/ObjectsList.qml b/resources/qml/ObjectsList.qml new file mode 100644 index 0000000000..105bdb957b --- /dev/null +++ b/resources/qml/ObjectsList.qml @@ -0,0 +1,88 @@ +// 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 QtQuick.Dialogs 1.1 + +import UM 1.3 as UM +import Cura 1.0 as Cura + +import "Menus" + +Rectangle +{ + id: base; + + color: UM.Theme.getColor("tool_panel_background") + + width: UM.Theme.getSize("objects_menu_size").width + height: UM.Theme.getSize("objects_menu_size").height + + Button + { + id: openFileButton; + text: catalog.i18nc("@action:button","Open File"); + iconSource: UM.Theme.getIcon("load") + style: UM.Theme.styles.tool_button + tooltip: ''; + anchors + { + top: parent.top; + topMargin: UM.Theme.getSize("default_margin").height; + left: parent.left; + leftMargin: UM.Theme.getSize("default_margin").height; + } + action: Cura.Actions.open; + } + + ListModel + { + id: objectsListModel; + + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } + } + + Component { + id: objectDelegate + Rectangle { + height: 30 + + Text { + text: name + color: red + } + //Text { text: '$' + cost } + } + } + + ListView + { + model: objectsListModel; + anchors + { + top: openFileButton.bottom; + topMargin: UM.Theme.getSize("default_margin").height; + left: parent.left; + leftMargin: UM.Theme.getSize("default_margin").height; + } + width: parent.width - 2 * UM.Theme.getSize("default_margin").height + height: 100 + + delegate: objectDelegate + } + +} diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index b41ea96846..315b29bec0 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -374,6 +374,8 @@ "infill_button_margin": [0.5, 0.5], - "jobspecs_line": [2.0, 2.0] + "jobspecs_line": [2.0, 2.0], + + "objects_menu_size": [20, 30] } }