Add control to set the number of extruders in Machine Settings

This commit is contained in:
fieldOfView 2017-03-10 23:17:03 +01:00
parent 0c74b4d108
commit e853d87779
2 changed files with 53 additions and 5 deletions

View file

@ -29,6 +29,7 @@ class MachineSettingsAction(MachineAction):
self._container_registry = ContainerRegistry.getInstance() self._container_registry = ContainerRegistry.getInstance()
self._container_registry.containerAdded.connect(self._onContainerAdded) self._container_registry.containerAdded.connect(self._onContainerAdded)
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged)
def _reset(self): def _reset(self):
global_container_stack = Application.getInstance().getGlobalContainerStack() global_container_stack = Application.getInstance().getGlobalContainerStack()
@ -67,13 +68,21 @@ class MachineSettingsAction(MachineAction):
def _onContainerAdded(self, container): def _onContainerAdded(self, container):
# Add this action as a supported action to all machine definitions # Add this action as a supported action to all machine definitions
if isinstance(container, DefinitionContainer) and container.getMetaDataEntry("type") == "machine": if isinstance(container, DefinitionContainer) and container.getMetaDataEntry("type") == "machine":
if container.getProperty("machine_extruder_count", "value") > 1:
# Multiextruder printers are not currently supported
Logger.log("d", "Not attaching MachineSettingsAction to %s; Multi-extrusion printers are not supported", container.getId())
return
Application.getInstance().getMachineActionManager().addSupportedAction(container.getId(), self.getKey()) Application.getInstance().getMachineActionManager().addSupportedAction(container.getId(), self.getKey())
def _onGlobalContainerChanged(self):
self.globalContainerChanged.emit()
globalContainerChanged = pyqtSignal()
@pyqtProperty(int, notify = globalContainerChanged)
def definedExtruderCount(self):
global_container_stack = Application.getInstance().getGlobalContainerStack()
if not global_container_stack:
return 0
return len(global_container_stack.getMetaDataEntry("machine_extruder_trains"))
@pyqtSlot() @pyqtSlot()
def forceUpdate(self): def forceUpdate(self):
# Force rebuilding the build volume by reloading the global container stack. # Force rebuilding the build volume by reloading the global container stack.

View file

@ -345,6 +345,35 @@ Cura.MachineAction
Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height } Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height } Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
Label
{
text: catalog.i18nc("@label", "Number of Extruders")
}
ComboBox
{
id: extruderCountComboBox
model: ListModel
{
id: extruderCountModel
Component.onCompleted:
{
for(var i = 0; i < manager.definedExtruderCount; i++)
{
extruderCountModel.append({text: String(i + 1), value: i});
}
}
}
currentIndex: machineExtruderCountProvider.properties.value - 1
onActivated:
{
machineExtruderCountProvider.setPropertyValue("value", index + 1);
manager.forceUpdate();
}
}
Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
Label Label
{ {
text: catalog.i18nc("@label", "Nozzle size") text: catalog.i18nc("@label", "Nozzle size")
@ -532,6 +561,16 @@ Cura.MachineAction
storeIndex: manager.containerIndex storeIndex: manager.containerIndex
} }
UM.SettingPropertyProvider
{
id: machineExtruderCountProvider
containerStackId: Cura.MachineManager.activeMachineId
key: "machine_extruder_count"
watchedProperties: [ "value" ]
storeIndex: manager.containerIndex
}
UM.SettingPropertyProvider UM.SettingPropertyProvider
{ {
id: gantryHeightProvider id: gantryHeightProvider