mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Move some convoluted logic from QML into Python
This commit is contained in:
parent
933ee408e4
commit
8d42f9c187
2 changed files with 35 additions and 38 deletions
|
@ -122,6 +122,40 @@ class MachineSettingsAction(MachineAction):
|
||||||
|
|
||||||
return len(self._global_container_stack.getMetaDataEntry("machine_extruder_trains"))
|
return len(self._global_container_stack.getMetaDataEntry("machine_extruder_trains"))
|
||||||
|
|
||||||
|
@pyqtSlot(int)
|
||||||
|
def setMachineExtruderCount(self, extruder_count):
|
||||||
|
machine_manager = Application.getInstance().getMachineManager()
|
||||||
|
extruder_manager = ExtruderManager.getInstance()
|
||||||
|
|
||||||
|
definition_changes_container = self._global_container_stack.findContainer({"type": "definition_changes"})
|
||||||
|
if not self._global_container_stack or not definition_changes_container:
|
||||||
|
return
|
||||||
|
|
||||||
|
if extruder_count == self._global_container_stack.getProperty("machine_extruder_count", "value"):
|
||||||
|
return
|
||||||
|
|
||||||
|
extruder_material = None
|
||||||
|
if extruder_count == 1 and machine_manager.hasMaterials:
|
||||||
|
extruder_material = machine_manager.allActiveMaterialIds[machine_manager.activeStackId]
|
||||||
|
|
||||||
|
definition_changes_container.setProperty("machine_extruder_count", "value", extruder_count)
|
||||||
|
self.forceUpdate()
|
||||||
|
|
||||||
|
if extruder_count > 1:
|
||||||
|
# multiextrusion; make sure one of these extruder stacks is active
|
||||||
|
if extruder_manager.activeExtruderIndex == -1:
|
||||||
|
extruder_manager.setActiveExtruderIndex(0)
|
||||||
|
else:
|
||||||
|
# single extrusion; make sure the machine stack is active
|
||||||
|
if extruder_manager.activeExtruderIndex > -1:
|
||||||
|
extruder_manager.setActiveExtruderIndex(-1);
|
||||||
|
|
||||||
|
if extruder_material:
|
||||||
|
# restore material on global stack
|
||||||
|
# MachineManager._onGlobalContainerChanged removes the global material of multiextruder machines
|
||||||
|
machine_manager.setActiveMaterial(extruder_material);
|
||||||
|
|
||||||
|
|
||||||
@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.
|
||||||
|
|
|
@ -377,48 +377,11 @@ Cura.MachineAction
|
||||||
currentIndex: machineExtruderCountProvider.properties.value - 1
|
currentIndex: machineExtruderCountProvider.properties.value - 1
|
||||||
onActivated:
|
onActivated:
|
||||||
{
|
{
|
||||||
if(machineExtruderCountProvider.properties.value == index + 1)
|
manager.setMachineExtruderCount(index + 1);
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var extruder_material;
|
|
||||||
if(index == 0 && Cura.MachineManager.hasMaterials)
|
|
||||||
{
|
|
||||||
// setting back to single extrusion
|
|
||||||
extruder_material = Cura.MachineManager.allActiveMaterialIds[Cura.MachineManager.activeStackId];
|
|
||||||
}
|
|
||||||
|
|
||||||
machineExtruderCountProvider.setPropertyValue("value", index + 1);
|
|
||||||
manager.forceUpdate();
|
|
||||||
base.extruderTabsCount = (index > 0) ? index + 1 : 0;
|
base.extruderTabsCount = (index > 0) ? index + 1 : 0;
|
||||||
|
|
||||||
if(index > 0)
|
|
||||||
{
|
|
||||||
// multiextrusion; make sure one of these extruder stacks is active
|
|
||||||
if(ExtruderManager.activeExtruderIndex == -1)
|
|
||||||
{
|
|
||||||
ExtruderManager.setActiveExtruderIndex(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// single extrusion; make sure the machine stack is active
|
|
||||||
if(ExtruderManager.activeExtruderIndex != -1)
|
|
||||||
{
|
|
||||||
ExtruderManager.setActiveExtruderIndex(-1);
|
|
||||||
}
|
|
||||||
if(extruder_material)
|
|
||||||
{
|
|
||||||
// restore material on global stack
|
|
||||||
// MachineManager._onGlobalContainerChanged removes the global material of multiextruder machines
|
|
||||||
Cura.MachineManager.setActiveMaterial(extruder_material);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@label", "Nozzle size")
|
text: catalog.i18nc("@label", "Nozzle size")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue