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) container_registry.addContainer(container_stack)
## Generates extruders for a specific machine. ## Generates extruders for a specific machine.
#
# \param machine_id The machine to get the extruders of.
def getMachineExtruders(self, machine_id): def getMachineExtruders(self, machine_id):
container_registry = UM.Settings.ContainerRegistry.getInstance() if machine_id not in self._extruder_trains:
if not machine_id in self._extruder_trains:
UM.Logger.log("w", "Tried to get the extruder trains for machine %s, which doesn't exist.", machine_id) UM.Logger.log("w", "Tried to get the extruder trains for machine %s, which doesn't exist.", machine_id)
return return
for name in self._extruder_trains[machine_id]: for name in self._extruder_trains[machine_id]:

View File

@ -28,6 +28,10 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
# containers. # containers.
IndexRole = Qt.UserRole + 4 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 ## Initialises the extruders model, defining the roles and listening for
# changes in the data. # changes in the data.
# #
@ -71,7 +75,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
if self._add_global: if self._add_global:
material = global_container_stack.findContainer({ "type": "material" }) 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 = { item = {
"id": global_container_stack.getId(), "id": global_container_stack.getId(),
"name": "Global", "name": "Global",
@ -80,9 +84,9 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
} }
self.appendItem(item) 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" }) 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. position = extruder.getBottom().getMetaDataEntry("position", default = "0") #Position in the definition.
try: try:
position = int(position) position = int(position)

View File

@ -1,11 +1,10 @@
# Copyright (c) 2016 Ultimaker B.V. # Copyright (c) 2016 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher. # Cura is released under the terms of the AGPLv3 or higher.
from PyQt5.QtCore import pyqtSignal
import copy import copy
from UM.Scene.SceneNodeDecorator import SceneNodeDecorator from UM.Scene.SceneNodeDecorator import SceneNodeDecorator
from UM.Signal import Signal, signalemitter
from UM.Settings.ContainerStack import ContainerStack from UM.Settings.ContainerStack import ContainerStack
from UM.Settings.InstanceContainer import InstanceContainer from UM.Settings.InstanceContainer import InstanceContainer
from UM.Settings.ContainerRegistry import ContainerRegistry 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 ## 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 # 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. # this stack still resolve.
@signalemitter
class SettingOverrideDecorator(SceneNodeDecorator): class SettingOverrideDecorator(SceneNodeDecorator):
## Event indicating that the user selected a different extruder. ## Event indicating that the user selected a different extruder.
activeExtruderChanged = pyqtSignal() activeExtruderChanged = Signal()
def __init__(self): def __init__(self):
super().__init__() super().__init__()

View File

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

View File

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