mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-30 04:05:25 +08:00
Merge branch 'master' of github.com:Ultimaker/Cura
This commit is contained in:
commit
84a9691390
@ -4,9 +4,8 @@
|
|||||||
from PyQt5.QtCore import pyqtSignal, pyqtProperty, pyqtSlot, QObject #For communicating data and events to Qt.
|
from PyQt5.QtCore import pyqtSignal, pyqtProperty, pyqtSlot, QObject #For communicating data and events to Qt.
|
||||||
|
|
||||||
import UM.Application #To get the global container stack to find the current machine.
|
import UM.Application #To get the global container stack to find the current machine.
|
||||||
import UM.Logger
|
from UM.Logger import Logger
|
||||||
import UM.Settings.ContainerRegistry #Finding containers by ID.
|
import UM.Settings.ContainerRegistry #Finding containers by ID.
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
## Manages all existing extruder stacks.
|
## Manages all existing extruder stacks.
|
||||||
@ -23,17 +22,8 @@ class ExtruderManager(QObject):
|
|||||||
def __init__(self, parent = None):
|
def __init__(self, parent = None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self._extruder_trains = { } #Extruders for the current machine.
|
self._extruder_trains = { } #Extruders for the current machine.
|
||||||
self._next_item = 0 #For when you use this class as iterator.
|
|
||||||
self._active_extruder_index = 0
|
self._active_extruder_index = 0
|
||||||
|
|
||||||
self._repopulate()
|
|
||||||
|
|
||||||
## Creates an iterator over the extruders in this manager.
|
|
||||||
#
|
|
||||||
# \return An iterator over the extruders in this manager.
|
|
||||||
def __iter__(self):
|
|
||||||
return iter(self._extruders)
|
|
||||||
|
|
||||||
## Gets the unique identifier of the currently active extruder stack.
|
## Gets the unique identifier of the currently active extruder stack.
|
||||||
#
|
#
|
||||||
# The currently active extruder stack is the stack that is currently being
|
# The currently active extruder stack is the stack that is currently being
|
||||||
@ -67,7 +57,7 @@ class ExtruderManager(QObject):
|
|||||||
# \param machine_definition The machine to add the extruders for.
|
# \param machine_definition The machine to add the extruders for.
|
||||||
def addMachineExtruders(self, machine_definition):
|
def addMachineExtruders(self, machine_definition):
|
||||||
machine_id = machine_definition.getId()
|
machine_id = machine_definition.getId()
|
||||||
if not self._extruder_trains[machine_id]:
|
if machine_id not in self._extruder_trains:
|
||||||
self._extruder_trains[machine_id] = { }
|
self._extruder_trains[machine_id] = { }
|
||||||
|
|
||||||
container_registry = UM.Settings.ContainerRegistry.getInstance()
|
container_registry = UM.Settings.ContainerRegistry.getInstance()
|
||||||
@ -82,7 +72,7 @@ class ExtruderManager(QObject):
|
|||||||
else:
|
else:
|
||||||
Logger.log("w", "Machine %s references an extruder with ID %s, which doesn't exist.", machine_definition.getName(), extruder_definition_id)
|
Logger.log("w", "Machine %s references an extruder with ID %s, which doesn't exist.", machine_definition.getName(), extruder_definition_id)
|
||||||
continue
|
continue
|
||||||
name = self._uniqueName(extruder_definition_id) #Make a name based on the ID of the definition.
|
name = container_registry.uniqueName(extruder_definition_id) #Make a name based on the ID of the definition.
|
||||||
if not container_registry.findContainerStacks(id = name): #Doesn't exist yet.
|
if not container_registry.findContainerStacks(id = name): #Doesn't exist yet.
|
||||||
self.createExtruderTrain(extruder_definition, machine_definition, name, position)
|
self.createExtruderTrain(extruder_definition, machine_definition, name, position)
|
||||||
|
|
||||||
@ -175,28 +165,3 @@ class ExtruderManager(QObject):
|
|||||||
container_stack.setNextStack(UM.Application.getInstance().getGlobalContainerStack())
|
container_stack.setNextStack(UM.Application.getInstance().getGlobalContainerStack())
|
||||||
|
|
||||||
container_registry.addContainer(container_stack)
|
container_registry.addContainer(container_stack)
|
||||||
|
|
||||||
## Creates a new unique name for a container that doesn't exist yet.
|
|
||||||
#
|
|
||||||
# It tries if the original name you provide exists, and if it doesn't
|
|
||||||
# it'll add a " #1" or " #2" after the name to make it unique.
|
|
||||||
#
|
|
||||||
# \param original The original name that may not be unique.
|
|
||||||
# \return A unique name that looks a lot like the original but may have
|
|
||||||
# a number behind it to make it unique.
|
|
||||||
def _uniqueName(self, original):
|
|
||||||
container_registry = UM.Settings.ContainerRegistry.getInstance()
|
|
||||||
|
|
||||||
name = original.strip()
|
|
||||||
num_check = re.compile("(.*?)\s*#\d$").match(name)
|
|
||||||
if num_check: # There is a number in the name.
|
|
||||||
name = num_check.group(1) # Filter out the number.
|
|
||||||
if name == "": # Wait, that deleted everything!
|
|
||||||
name = "Extruder"
|
|
||||||
unique_name = name
|
|
||||||
|
|
||||||
i = 1
|
|
||||||
while container_registry.findContainers(id = unique_name) or container_registry.findContainers(name = unique_name): # A container already has this name.
|
|
||||||
i += 1 # Try next numbering.
|
|
||||||
unique_name = "%s #%d" % (name, i) # Fill name like this: "Extruder #2".
|
|
||||||
return unique_name
|
|
||||||
|
@ -64,24 +64,26 @@ Item {
|
|||||||
settingLoader.item.doDepthIdentation = false
|
settingLoader.item.doDepthIdentation = false
|
||||||
}
|
}
|
||||||
|
|
||||||
source:
|
sourceComponent:
|
||||||
{
|
{
|
||||||
switch(model.type) // TODO: This needs to be fixed properly. Got frustrated with it not working, so this is the patch job!
|
switch(model.type)
|
||||||
{
|
{
|
||||||
case "int":
|
case "int":
|
||||||
return "../../resources/qml/Settings/SettingTextField.qml"
|
return settingTextField
|
||||||
case "float":
|
case "float":
|
||||||
return "../../resources/qml/Settings/SettingTextField.qml"
|
return settingTextField
|
||||||
case "enum":
|
case "enum":
|
||||||
return "../../resources/qml/Settings/SettingComboBox.qml"
|
return settingComboBox
|
||||||
|
case "extruder":
|
||||||
|
return settingExtruder
|
||||||
case "bool":
|
case "bool":
|
||||||
return "../../resources/qml/Settings/SettingCheckBox.qml"
|
return settingCheckBox
|
||||||
case "str":
|
case "str":
|
||||||
return "../../resources/qml/Settings/SettingTextField.qml"
|
return settingTextField
|
||||||
case "category":
|
case "category":
|
||||||
return "../../resources/qml/Settings/SettingCategory.qml"
|
return settingCategory
|
||||||
default:
|
default:
|
||||||
return "../../resources/qml/Settings/SettingUnknown.qml"
|
return settingUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,4 +259,46 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SystemPalette { id: palette; }
|
SystemPalette { id: palette; }
|
||||||
|
|
||||||
|
Component
|
||||||
|
{
|
||||||
|
id: settingTextField;
|
||||||
|
|
||||||
|
Cura.SettingTextField { }
|
||||||
|
}
|
||||||
|
|
||||||
|
Component
|
||||||
|
{
|
||||||
|
id: settingComboBox;
|
||||||
|
|
||||||
|
Cura.SettingComboBox { }
|
||||||
|
}
|
||||||
|
|
||||||
|
Component
|
||||||
|
{
|
||||||
|
id: settingExtruder;
|
||||||
|
|
||||||
|
Cura.SettingExtruder { }
|
||||||
|
}
|
||||||
|
|
||||||
|
Component
|
||||||
|
{
|
||||||
|
id: settingCheckBox;
|
||||||
|
|
||||||
|
Cura.SettingCheckBox { }
|
||||||
|
}
|
||||||
|
|
||||||
|
Component
|
||||||
|
{
|
||||||
|
id: settingCategory;
|
||||||
|
|
||||||
|
Cura.SettingCategory { }
|
||||||
|
}
|
||||||
|
|
||||||
|
Component
|
||||||
|
{
|
||||||
|
id: settingUnknown;
|
||||||
|
|
||||||
|
Cura.SettingUnknown { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user