mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Add a legend to Layer View
This commit is contained in:
parent
f0333e2184
commit
878ccc679c
4 changed files with 107 additions and 0 deletions
|
@ -315,6 +315,11 @@ class CuraApplication(QtApplication):
|
|||
|
||||
showPrintMonitor = pyqtSignal(bool, arguments = ["show"])
|
||||
|
||||
def setViewLegendItems(self, items):
|
||||
self.viewLegendItemsChanged.emit(items)
|
||||
|
||||
viewLegendItemsChanged = pyqtSignal("QVariantList", arguments = ["items"])
|
||||
|
||||
## Cura has multiple locations where instance containers need to be saved, so we need to handle this differently.
|
||||
#
|
||||
# Note that the AutoSave plugin also calls this method.
|
||||
|
|
|
@ -60,6 +60,8 @@ class LayerView(View):
|
|||
self._proxy = LayerViewProxy.LayerViewProxy()
|
||||
self._controller.getScene().getRoot().childrenChanged.connect(self._onSceneChanged)
|
||||
|
||||
self._legend_items = None
|
||||
|
||||
Preferences.getInstance().addPreference("view/top_layer_count", 5)
|
||||
Preferences.getInstance().addPreference("view/only_show_top_layers", False)
|
||||
Preferences.getInstance().preferenceChanged.connect(self._onPreferencesChanged)
|
||||
|
@ -206,6 +208,8 @@ class LayerView(View):
|
|||
self._old_composite_shader = self._composite_pass.getCompositeShader()
|
||||
self._composite_pass.setCompositeShader(self._layerview_composite_shader)
|
||||
|
||||
Application.getInstance().setViewLegendItems(self._getLegendItems())
|
||||
|
||||
elif event.type == Event.ViewDeactivateEvent:
|
||||
self._wireprint_warning_message.hide()
|
||||
Application.getInstance().globalContainerStackChanged.disconnect(self._onGlobalStackChanged)
|
||||
|
@ -215,6 +219,8 @@ class LayerView(View):
|
|||
self._composite_pass.setLayerBindings(self._old_layer_bindings)
|
||||
self._composite_pass.setCompositeShader(self._old_composite_shader)
|
||||
|
||||
Application.getInstance().setViewLegendItems([])
|
||||
|
||||
def _onGlobalStackChanged(self):
|
||||
if self._global_container_stack:
|
||||
self._global_container_stack.propertyChanged.disconnect(self._onPropertyChanged)
|
||||
|
@ -264,6 +270,24 @@ class LayerView(View):
|
|||
|
||||
self._startUpdateTopLayers()
|
||||
|
||||
def _getLegendItems(self):
|
||||
if self._legend_items is None:
|
||||
theme = Application.getInstance().getTheme()
|
||||
self._legend_items = [
|
||||
{"color": theme.getColor("layerview_inset_0").name(), "title": catalog.i18nc("@label:layerview polygon type", "Outer Wall")}, # Inset0Type
|
||||
{"color": theme.getColor("layerview_inset_x").name(), "title": catalog.i18nc("@label:layerview polygon type", "Inner Wall")}, # InsetXType
|
||||
{"color": theme.getColor("layerview_skin").name(), "title": catalog.i18nc("@label:layerview polygon type", "Top / Bottom")}, # SkinType
|
||||
{"color": theme.getColor("layerview_infill").name(), "title": catalog.i18nc("@label:layerview polygon type", "Infill")}, # InfillType
|
||||
{"color": theme.getColor("layerview_support").name(), "title": catalog.i18nc("@label:layerview polygon type", "Support Skin")}, # SupportType
|
||||
{"color": theme.getColor("layerview_support_infill").name(), "title": catalog.i18nc("@label:layerview polygon type", "Support Infill")}, # SupportInfillType
|
||||
{"color": theme.getColor("layerview_support_interface").name(), "title": catalog.i18nc("@label:layerview polygon type", "Support Interface")}, # SupportInterfaceType
|
||||
{"color": theme.getColor("layerview_skirt").name(), "title": catalog.i18nc("@label:layerview polygon type", "Build Plate Adhesion")}, # SkirtType
|
||||
{"color": theme.getColor("layerview_move_combing").name(), "title": catalog.i18nc("@label:layerview polygon type", "Travel Move")}, # MoveCombingType
|
||||
{"color": theme.getColor("layerview_move_retraction").name(), "title": catalog.i18nc("@label:layerview polygon type", "Retraction Move")}, # MoveRetractionType
|
||||
#{"color": theme.getColor("layerview_none").name(), "title": catalog.i18nc("@label:layerview polygon type", "Unknown")} # NoneType
|
||||
]
|
||||
return self._legend_items
|
||||
|
||||
|
||||
class _CreateTopLayersJob(Job):
|
||||
def __init__(self, scene, layer_number, solid_layers):
|
||||
|
|
|
@ -306,6 +306,18 @@ UM.MainWindow
|
|||
}
|
||||
}
|
||||
|
||||
Legend
|
||||
{
|
||||
id: legend
|
||||
anchors
|
||||
{
|
||||
top: parent.top
|
||||
topMargin: UM.Theme.getSize("default_margin").height
|
||||
right: sidebar.left
|
||||
rightMargin: UM.Theme.getSize("default_margin").width
|
||||
}
|
||||
}
|
||||
|
||||
JobSpecs
|
||||
{
|
||||
id: jobSpecs
|
||||
|
|
66
resources/qml/Legend.qml
Normal file
66
resources/qml/Legend.qml
Normal file
|
@ -0,0 +1,66 @@
|
|||
// Copyright (c) 2015 Ultimaker B.V.
|
||||
// Cura is released under the terms of the AGPLv3 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.1 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
||||
Rectangle {
|
||||
id: base
|
||||
|
||||
UM.I18nCatalog { id: catalog; name:"cura"}
|
||||
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
color: "transparent"
|
||||
|
||||
Connections
|
||||
{
|
||||
target: Printer
|
||||
onViewLegendItemsChanged:
|
||||
{
|
||||
legendItemRepeater.model = items
|
||||
}
|
||||
}
|
||||
|
||||
Column
|
||||
{
|
||||
Repeater
|
||||
{
|
||||
id: legendItemRepeater
|
||||
|
||||
Item {
|
||||
anchors.right: parent.right
|
||||
height: childrenRect.height
|
||||
width: childrenRect.width
|
||||
|
||||
Rectangle {
|
||||
id: swatch
|
||||
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: label.verticalCenter
|
||||
height: UM.Theme.getSize("setting_control").height / 2
|
||||
width: height
|
||||
|
||||
color: modelData.color
|
||||
border.width: UM.Theme.getSize("default_lining").width
|
||||
border.color: UM.Theme.getColor("text_subtext")
|
||||
}
|
||||
Label {
|
||||
id: label
|
||||
|
||||
text: modelData.title
|
||||
font: UM.Theme.getFont("small")
|
||||
color: UM.Theme.getColor("text_subtext")
|
||||
|
||||
anchors.right: swatch.left
|
||||
anchors.rightMargin: UM.Theme.getSize("default_margin").width / 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue