This commit is contained in:
fieldOfView 2016-06-09 17:49:49 +02:00
commit 4da69a4d3e
5 changed files with 15 additions and 11 deletions

View file

@ -191,9 +191,10 @@ class ExtruderManager(QObject):
container_registry.addContainer(container_stack)
## Generates extruders for a specific machine.
#
# \param machine_id The machine to get the extruders of.
def getMachineExtruders(self, machine_id):
container_registry = UM.Settings.ContainerRegistry.getInstance()
if not machine_id in self._extruder_trains:
if machine_id not in self._extruder_trains:
UM.Logger.log("w", "Tried to get the extruder trains for machine %s, which doesn't exist.", machine_id)
return
for name in self._extruder_trains[machine_id]:

View file

@ -28,6 +28,10 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
# containers.
IndexRole = Qt.UserRole + 4
## Colour to display if there is no material or the material has no known
# colour.
defaultColour = "#FFFF00"
## Initialises the extruders model, defining the roles and listening for
# changes in the data.
#
@ -71,7 +75,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
if self._add_global:
material = global_container_stack.findContainer({ "type": "material" })
colour = material.getMetaDataEntry("color_code", default = "#FFFF00") if material else "#FFFF00"
colour = material.getMetaDataEntry("color_code", default = self.defaultColour) if material else self.defaultColour
item = {
"id": global_container_stack.getId(),
"name": "Global",
@ -80,9 +84,9 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
}
self.appendItem(item)
for extruder in manager.getMachineExtruders(global_container_stack.getBottom()):
for extruder in manager.getMachineExtruders(global_container_stack.getBottom().getId()):
material = extruder.findContainer({ "type": "material" })
colour = material.getMetaDataEntry("color_code", default = "#FFFF00") if material else "#FFFF00"
colour = material.getMetaDataEntry("color_code", default = self.defaultColour) if material else self.defaultColour
position = extruder.getBottom().getMetaDataEntry("position", default = "0") #Position in the definition.
try:
position = int(position)

View file

@ -1,11 +1,10 @@
# Copyright (c) 2016 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher.
from PyQt5.QtCore import pyqtSignal
import copy
from UM.Scene.SceneNodeDecorator import SceneNodeDecorator
from UM.Signal import Signal, signalemitter
from UM.Settings.ContainerStack import ContainerStack
from UM.Settings.InstanceContainer import InstanceContainer
from UM.Settings.ContainerRegistry import ContainerRegistry
@ -15,9 +14,10 @@ from UM.Application import Application
## A decorator that adds a container stack to a Node. This stack should be queried for all settings regarding
# the linked node. The Stack in question will refer to the global stack (so that settings that are not defined by
# this stack still resolve.
@signalemitter
class SettingOverrideDecorator(SceneNodeDecorator):
## Event indicating that the user selected a different extruder.
activeExtruderChanged = pyqtSignal()
activeExtruderChanged = Signal()
def __init__(self):
super().__init__()

View file

@ -36,6 +36,7 @@ Item {
{
id: extruders_model
}
visible: extruders_model.rowCount() > 1
textRole: "name"
width: items.width
height: UM.Theme.getSize("section").height

View file

@ -324,7 +324,6 @@
"minimum_value": "0.001",
"minimum_value_warning": "0.04",
"maximum_value_warning": "0.8 * machine_nozzle_size",
"default_value": true,
"settable_per_mesh": false,
"settable_per_extruder": false
},
@ -338,7 +337,6 @@
"minimum_value": "0.001",
"minimum_value_warning": "0.04",
"maximum_value_warning": "0.8 * machine_nozzle_size",
"default_value": true,
"settable_per_mesh": false,
"settable_per_extruder": false
},
@ -353,6 +351,7 @@
"default_value": 0.4,
"type": "float",
"value": "machine_nozzle_size",
"settable_per_mesh": true,
"children":
{
"wall_line_width":
@ -366,7 +365,6 @@
"value":"line_width",
"default_value": 0.4,
"type": "float",
"default_value": true,
"settable_per_mesh": true,
"children":
{