mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-04 11:14:21 +08:00
Merge branch 'fieldOfView-feature_machine_settings_fixes'
This commit is contained in:
commit
a8547ed8be
@ -380,6 +380,8 @@ class CuraApplication(QtApplication):
|
||||
path = Resources.getStoragePath(self.ResourceTypes.UserInstanceContainer, file_name)
|
||||
elif instance_type == "variant":
|
||||
path = Resources.getStoragePath(self.ResourceTypes.VariantInstanceContainer, file_name)
|
||||
elif instance_type == "definition_changes":
|
||||
path = Resources.getStoragePath(self.ResourceTypes.MachineStack, file_name)
|
||||
|
||||
if path:
|
||||
instance.setPath(path)
|
||||
|
@ -1,14 +1,14 @@
|
||||
# Copyright (c) 2016 Ultimaker B.V.
|
||||
# Cura is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot
|
||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot
|
||||
|
||||
from cura.MachineAction import MachineAction
|
||||
import cura.Settings.CuraContainerRegistry
|
||||
|
||||
import UM.Application
|
||||
import UM.Settings.InstanceContainer
|
||||
import UM.Settings.DefinitionContainer
|
||||
import UM.Settings.ContainerRegistry
|
||||
import UM.Logger
|
||||
|
||||
import UM.i18n
|
||||
@ -19,23 +19,44 @@ class MachineSettingsAction(MachineAction):
|
||||
super().__init__("MachineSettingsAction", catalog.i18nc("@action", "Machine Settings"))
|
||||
self._qml_url = "MachineSettingsAction.qml"
|
||||
|
||||
cura.Settings.CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerAdded)
|
||||
self._container_index = 0
|
||||
|
||||
self._container_registry = UM.Settings.ContainerRegistry.getInstance()
|
||||
self._container_registry.containerAdded.connect(self._onContainerAdded)
|
||||
|
||||
def _reset(self):
|
||||
global_container_stack = UM.Application.getInstance().getGlobalContainerStack()
|
||||
if global_container_stack:
|
||||
variant = global_container_stack.findContainer({"type": "variant"})
|
||||
if variant and variant.getId() == "empty_variant":
|
||||
variant_index = global_container_stack.getContainerIndex(variant)
|
||||
self._createVariant(global_container_stack, variant_index)
|
||||
if not global_container_stack:
|
||||
return
|
||||
|
||||
def _createVariant(self, global_container_stack, variant_index):
|
||||
# Create and switch to a variant to store the settings in
|
||||
new_variant = UM.Settings.InstanceContainer(global_container_stack.getName() + "_variant")
|
||||
new_variant.addMetaDataEntry("type", "variant")
|
||||
new_variant.setDefinition(global_container_stack.getBottom())
|
||||
UM.Settings.ContainerRegistry.getInstance().addContainer(new_variant)
|
||||
global_container_stack.replaceContainer(variant_index, new_variant)
|
||||
# Make sure there is a definition_changes container to store the machine settings
|
||||
definition_changes_container = global_container_stack.findContainer({"type": "definition_changes"})
|
||||
if not definition_changes_container:
|
||||
definition_changes_container = self._createDefinitionChangesContainer(global_container_stack)
|
||||
|
||||
# Notify the UI in which container to store the machine settings data
|
||||
container_index = global_container_stack.getContainerIndex(definition_changes_container)
|
||||
if container_index != self._container_index:
|
||||
self._container_index = container_index
|
||||
self.containerIndexChanged.emit()
|
||||
|
||||
def _createDefinitionChangesContainer(self, global_container_stack, container_index = None):
|
||||
definition_changes_container = UM.Settings.InstanceContainer(global_container_stack.getName() + "_settings")
|
||||
definition = global_container_stack.getBottom()
|
||||
definition_changes_container.setDefinition(definition)
|
||||
definition_changes_container.addMetaDataEntry("type", "definition_changes")
|
||||
|
||||
self._container_registry.addContainer(definition_changes_container)
|
||||
# Insert definition_changes between the definition and the variant
|
||||
global_container_stack.insertContainer(-1, definition_changes_container)
|
||||
|
||||
return definition_changes_container
|
||||
|
||||
containerIndexChanged = pyqtSignal()
|
||||
|
||||
@pyqtProperty(int, notify = containerIndexChanged)
|
||||
def containerIndex(self):
|
||||
return self._container_index
|
||||
|
||||
def _onContainerAdded(self, container):
|
||||
# Add this action as a supported action to all machine definitions
|
||||
@ -44,10 +65,6 @@ class MachineSettingsAction(MachineAction):
|
||||
# Multiextruder printers are not currently supported
|
||||
UM.Logger.log("d", "Not attaching MachineSettingsAction to %s; Multi-extrusion printers are not supported", container.getId())
|
||||
return
|
||||
if container.getMetaDataEntry("has_variants", False):
|
||||
# Machines that use variants are not currently supported
|
||||
UM.Logger.log("d", "Not attaching MachineSettingsAction to %s; Machines that use variants are not supported", container.getId())
|
||||
return
|
||||
|
||||
UM.Application.getInstance().getMachineActionManager().addSupportedAction(container.getId(), self.getKey())
|
||||
|
||||
@ -78,7 +95,7 @@ class MachineSettingsAction(MachineAction):
|
||||
# Set the material container to a sane default
|
||||
if material_container.getId() == "empty_material":
|
||||
search_criteria = { "type": "material", "definition": "fdmprinter", "id": "*pla*" }
|
||||
containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(**search_criteria)
|
||||
containers = self._container_registry.findInstanceContainers(**search_criteria)
|
||||
if containers:
|
||||
global_container_stack.replaceContainer(material_index, containers[0])
|
||||
else:
|
||||
@ -87,7 +104,7 @@ class MachineSettingsAction(MachineAction):
|
||||
if "has_materials" in global_container_stack.getMetaData():
|
||||
global_container_stack.removeMetaDataEntry("has_materials")
|
||||
|
||||
empty_material = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id = "empty_material")[0]
|
||||
empty_material = self._container_registry.findInstanceContainers(id = "empty_material")[0]
|
||||
global_container_stack.replaceContainer(material_index, empty_material)
|
||||
|
||||
UM.Application.getInstance().globalContainerStackChanged.emit()
|
@ -147,19 +147,40 @@ Cura.MachineAction
|
||||
|
||||
ComboBox
|
||||
{
|
||||
model: ["RepRap (Marlin/Sprinter)", "UltiGCode", "Repetier"]
|
||||
model: ListModel
|
||||
{
|
||||
id: flavorModel
|
||||
Component.onCompleted:
|
||||
{
|
||||
// Options come in as a string-representation of an OrderedDict
|
||||
var options = machineGCodeFlavorProvider.properties.options.match(/^OrderedDict\(\[\((.*)\)\]\)$/);
|
||||
if(options)
|
||||
{
|
||||
options = options[1].split("), (")
|
||||
for(var i = 0; i < options.length; i++)
|
||||
{
|
||||
var option = options[i].substring(1, options[i].length - 1).split("', '")
|
||||
flavorModel.append({text: option[1], value: option[0]});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
currentIndex:
|
||||
{
|
||||
var index = model.indexOf(machineGCodeFlavorProvider.properties.value);
|
||||
if(index == -1)
|
||||
var currentValue = machineGCodeFlavorProvider.properties.value;
|
||||
var index = 0;
|
||||
for(var i = 0; i < flavorModel.count; i++)
|
||||
{
|
||||
index = 0;
|
||||
if(flavorModel.get(i).value == currentValue) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index
|
||||
}
|
||||
onActivated:
|
||||
{
|
||||
machineGCodeFlavorProvider.setPropertyValue("value", model[index]);
|
||||
machineGCodeFlavorProvider.setPropertyValue("value", flavorModel.get(index).value);
|
||||
manager.updateHasMaterialsMetadata();
|
||||
}
|
||||
}
|
||||
@ -273,17 +294,20 @@ Cura.MachineAction
|
||||
Label
|
||||
{
|
||||
text: catalog.i18nc("@label", "Nozzle size")
|
||||
visible: !Cura.MachineManager.hasVariants
|
||||
}
|
||||
TextField
|
||||
{
|
||||
id: nozzleSizeField
|
||||
text: machineNozzleSizeProvider.properties.value
|
||||
visible: !Cura.MachineManager.hasVariants
|
||||
validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
|
||||
onEditingFinished: { machineNozzleSizeProvider.setPropertyValue("value", text) }
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: catalog.i18nc("@label", "mm")
|
||||
visible: !Cura.MachineManager.hasVariants
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -308,6 +332,8 @@ Cura.MachineAction
|
||||
id: machineStartGcodeField
|
||||
width: parent.width
|
||||
height: parent.height - y
|
||||
font: UM.Theme.getFont("fixed")
|
||||
wrapMode: TextEdit.NoWrap
|
||||
text: machineStartGcodeProvider.properties.value
|
||||
onActiveFocusChanged:
|
||||
{
|
||||
@ -330,6 +356,8 @@ Cura.MachineAction
|
||||
id: machineEndGcodeField
|
||||
width: parent.width
|
||||
height: parent.height - y
|
||||
font: UM.Theme.getFont("fixed")
|
||||
wrapMode: TextEdit.NoWrap
|
||||
text: machineEndGcodeProvider.properties.value
|
||||
onActiveFocusChanged:
|
||||
{
|
||||
@ -377,7 +405,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_width"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 4
|
||||
storeIndex: manager.containerIndex
|
||||
}
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
@ -387,7 +415,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_depth"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 4
|
||||
storeIndex: manager.containerIndex
|
||||
}
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
@ -397,7 +425,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_height"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 4
|
||||
storeIndex: manager.containerIndex
|
||||
}
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
@ -407,7 +435,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_heated_bed"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 4
|
||||
storeIndex: manager.containerIndex
|
||||
}
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
@ -417,7 +445,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_center_is_zero"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 4
|
||||
storeIndex: manager.containerIndex
|
||||
}
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
@ -426,8 +454,8 @@ Cura.MachineAction
|
||||
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_gcode_flavor"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 4
|
||||
watchedProperties: [ "value", "options" ]
|
||||
storeIndex: manager.containerIndex
|
||||
}
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
@ -437,7 +465,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_nozzle_size"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 4
|
||||
storeIndex: manager.containerIndex
|
||||
}
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
@ -447,7 +475,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "gantry_height"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 4
|
||||
storeIndex: manager.containerIndex
|
||||
}
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
@ -457,7 +485,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_head_with_fans_polygon"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 4
|
||||
storeIndex: manager.containerIndex
|
||||
}
|
||||
|
||||
|
||||
@ -468,7 +496,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_start_gcode"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 4
|
||||
storeIndex: manager.containerIndex
|
||||
}
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
@ -478,7 +506,7 @@ Cura.MachineAction
|
||||
containerStackId: Cura.MachineManager.activeMachineId
|
||||
key: "machine_end_gcode"
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 4
|
||||
storeIndex: manager.containerIndex
|
||||
}
|
||||
|
||||
}
|
@ -27,19 +27,23 @@ class UMOUpgradeSelection(MachineAction):
|
||||
def setHeatedBed(self, heated_bed = True):
|
||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||
if global_container_stack:
|
||||
variant = global_container_stack.findContainer({"type": "variant"})
|
||||
if variant:
|
||||
if variant.getId() == "empty_variant":
|
||||
variant_index = global_container_stack.getContainerIndex(variant)
|
||||
variant = self._createVariant(global_container_stack, variant_index)
|
||||
variant.setProperty("machine_heated_bed", "value", heated_bed)
|
||||
self.heatedBedChanged.emit()
|
||||
# Make sure there is a definition_changes container to store the machine settings
|
||||
definition_changes_container = global_container_stack.findContainer({"type": "definition_changes"})
|
||||
if not definition_changes_container:
|
||||
definition_changes_container = self._createDefinitionChangesContainer(global_container_stack)
|
||||
|
||||
def _createVariant(self, global_container_stack, variant_index):
|
||||
# Create and switch to a variant to store the settings in
|
||||
new_variant = UM.Settings.InstanceContainer(global_container_stack.getName() + "_variant")
|
||||
new_variant.addMetaDataEntry("type", "variant")
|
||||
new_variant.setDefinition(global_container_stack.getBottom())
|
||||
UM.Settings.ContainerRegistry.getInstance().addContainer(new_variant)
|
||||
global_container_stack.replaceContainer(variant_index, new_variant)
|
||||
return new_variant
|
||||
definition_changes_container.setProperty("machine_heated_bed", "value", heated_bed)
|
||||
self.heatedBedChanged.emit()
|
||||
|
||||
def _createDefinitionChangesContainer(self, global_container_stack):
|
||||
# Create a definition_changes container to store the settings in and add it to the stack
|
||||
definition_changes_container = UM.Settings.InstanceContainer(global_container_stack.getName() + "_settings")
|
||||
definition = global_container_stack.getBottom()
|
||||
definition_changes_container.setDefinition(definition)
|
||||
definition_changes_container.addMetaDataEntry("type", "definition_changes")
|
||||
|
||||
UM.Settings.ContainerRegistry.getInstance().addContainer(definition_changes_container)
|
||||
# Insert definition_changes between the definition and the variant
|
||||
global_container_stack.insertContainer(-1, definition_changes_container)
|
||||
|
||||
return definition_changes_container
|
||||
|
Loading…
x
Reference in New Issue
Block a user