diff options
author | Ghostkeeper <rubend@tutanota.com> | 2017-02-03 16:52:09 +0300 |
---|---|---|
committer | Ghostkeeper <rubend@tutanota.com> | 2017-02-03 16:52:09 +0300 |
commit | ee3e0ba6abb659cd1a1b5322b6da6ab3d75ba18b (patch) | |
tree | 40c39666708263424f3221001c6179056122b200 /cura/PrinterOutputDevice.py | |
parent | 687cdcc30ea4c74dc02e5012f82c445c105b87e7 (diff) |
Add material indication to extruder boxes
Only if a material is known of course. But the case where it is unknown is not tested.
Contributes to issue CURA-3161.
Diffstat (limited to 'cura/PrinterOutputDevice.py')
-rw-r--r-- | cura/PrinterOutputDevice.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index 6e7305b27b..ed67bbb1ca 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -323,6 +323,28 @@ class PrinterOutputDevice(QObject, OutputDevice): result.append(i18n_catalog.i18nc("@item:material", "Unknown material")) return result + ## List of the colours of the currently loaded materials. + # + # The list is in order of extruders. If there is no material in an + # extruder, the colour is shown as transparent. + # + # The colours are returned in hex-format AARRGGBB or RRGGBB + # (e.g. #800000ff for transparent blue or #00ff00 for pure green). + @pyqtProperty("QVariantList", notify = materialIdChanged) + def materialColors(self): + result = [] + for material_id in self._material_ids: + if material_id is None: + result.append("#800000FF") #No material. + continue + + containers = self._container_registry.findInstanceContainers(type = "material", GUID = material_id) + if containers: + result.append(containers[0].getMetaDataEntry("color_code")) + else: + result.append("#800000FF") #Unknown material. + return result + ## Protected setter for the current material id. # /param index Index of the extruder # /param material_id id of the material |