mirror of
https://github.com/Ultimaker/Cura.git
synced 2026-03-14 23:35:58 -06:00
Merge remote-tracking branch 'origin/CURA-12730_fix-paint-switch-2-to-4-extruders' into CURA-12740_multi-material-with-ex2
This commit is contained in:
commit
0b4ebe57de
2 changed files with 13 additions and 5 deletions
|
|
@ -2,7 +2,7 @@
|
|||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from PyQt6.QtCore import Qt, pyqtSignal, pyqtProperty, QTimer
|
||||
from typing import Iterable, TYPE_CHECKING
|
||||
from typing import Iterable, TYPE_CHECKING, Optional, Dict, Any
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
from UM.Qt.ListModel import ListModel
|
||||
|
|
@ -104,6 +104,9 @@ class ExtrudersModel(ListModel):
|
|||
self.addOptionalExtruderChanged.emit()
|
||||
self._updateExtruders()
|
||||
|
||||
def getExtruderItem(self, extruder_index: int) -> Optional[Dict[str, Any]]:
|
||||
return next((item for item in self.items if item["index"] == extruder_index), None)
|
||||
|
||||
@pyqtProperty(bool, fset = setAddOptionalExtruder, notify = addOptionalExtruderChanged)
|
||||
def addOptionalExtruder(self):
|
||||
return self._add_optional_extruder
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ catalog = i18nCatalog("cura")
|
|||
class PaintView(CuraView):
|
||||
"""View for model-painting."""
|
||||
|
||||
MAX_EXTRUDER_COUNT = 16
|
||||
|
||||
class PaintType:
|
||||
def __init__(self, display_color: Color, value: int):
|
||||
self.display_color: Color = display_color
|
||||
|
|
@ -114,14 +116,17 @@ class PaintView(CuraView):
|
|||
def _makeExtrudersColors(self) -> Dict[str, "PaintView.PaintType"]:
|
||||
extruders_colors: Dict[str, "PaintView.PaintType"] = {}
|
||||
|
||||
for extruder_item in self._extruders_model.items:
|
||||
if "color" in extruder_item:
|
||||
for extruder_index in range(PaintView.MAX_EXTRUDER_COUNT):
|
||||
extruder_item = self._extruders_model.getExtruderItem(extruder_index)
|
||||
if extruder_item is None:
|
||||
extruder_item = self._extruders_model.getExtruderItem(0)
|
||||
|
||||
if extruder_item is not None and "color" in extruder_item:
|
||||
material_color = extruder_item["color"]
|
||||
else:
|
||||
material_color = self._extruders_model.defaultColors[0]
|
||||
|
||||
index = extruder_item["index"]
|
||||
extruders_colors[str(index)] = self.PaintType(Color(*QColor(material_color).getRgb()), index)
|
||||
extruders_colors[str(extruder_index)] = self.PaintType(Color(*QColor(material_color).getRgb()), extruder_index)
|
||||
|
||||
return extruders_colors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue