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)
|
path = Resources.getStoragePath(self.ResourceTypes.UserInstanceContainer, file_name)
|
||||||
elif instance_type == "variant":
|
elif instance_type == "variant":
|
||||||
path = Resources.getStoragePath(self.ResourceTypes.VariantInstanceContainer, file_name)
|
path = Resources.getStoragePath(self.ResourceTypes.VariantInstanceContainer, file_name)
|
||||||
|
elif instance_type == "definition_changes":
|
||||||
|
path = Resources.getStoragePath(self.ResourceTypes.MachineStack, file_name)
|
||||||
|
|
||||||
if path:
|
if path:
|
||||||
instance.setPath(path)
|
instance.setPath(path)
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
# 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 pyqtSlot
|
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot
|
||||||
|
|
||||||
from cura.MachineAction import MachineAction
|
from cura.MachineAction import MachineAction
|
||||||
import cura.Settings.CuraContainerRegistry
|
|
||||||
|
|
||||||
import UM.Application
|
import UM.Application
|
||||||
import UM.Settings.InstanceContainer
|
import UM.Settings.InstanceContainer
|
||||||
import UM.Settings.DefinitionContainer
|
import UM.Settings.DefinitionContainer
|
||||||
|
import UM.Settings.ContainerRegistry
|
||||||
import UM.Logger
|
import UM.Logger
|
||||||
|
|
||||||
import UM.i18n
|
import UM.i18n
|
||||||
@ -19,23 +19,44 @@ class MachineSettingsAction(MachineAction):
|
|||||||
super().__init__("MachineSettingsAction", catalog.i18nc("@action", "Machine Settings"))
|
super().__init__("MachineSettingsAction", catalog.i18nc("@action", "Machine Settings"))
|
||||||
self._qml_url = "MachineSettingsAction.qml"
|
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):
|
def _reset(self):
|
||||||
global_container_stack = UM.Application.getInstance().getGlobalContainerStack()
|
global_container_stack = UM.Application.getInstance().getGlobalContainerStack()
|
||||||
if global_container_stack:
|
if not global_container_stack:
|
||||||
variant = global_container_stack.findContainer({"type": "variant"})
|
return
|
||||||
if variant and variant.getId() == "empty_variant":
|
|
||||||
variant_index = global_container_stack.getContainerIndex(variant)
|
|
||||||
self._createVariant(global_container_stack, variant_index)
|
|
||||||
|
|
||||||
def _createVariant(self, global_container_stack, variant_index):
|
# Make sure there is a definition_changes container to store the machine settings
|
||||||
# Create and switch to a variant to store the settings in
|
definition_changes_container = global_container_stack.findContainer({"type": "definition_changes"})
|
||||||
new_variant = UM.Settings.InstanceContainer(global_container_stack.getName() + "_variant")
|
if not definition_changes_container:
|
||||||
new_variant.addMetaDataEntry("type", "variant")
|
definition_changes_container = self._createDefinitionChangesContainer(global_container_stack)
|
||||||
new_variant.setDefinition(global_container_stack.getBottom())
|
|
||||||
UM.Settings.ContainerRegistry.getInstance().addContainer(new_variant)
|
# Notify the UI in which container to store the machine settings data
|
||||||
global_container_stack.replaceContainer(variant_index, new_variant)
|
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):
|
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
|
||||||
@ -44,10 +65,6 @@ class MachineSettingsAction(MachineAction):
|
|||||||
# Multiextruder printers are not currently supported
|
# Multiextruder printers are not currently supported
|
||||||
UM.Logger.log("d", "Not attaching MachineSettingsAction to %s; Multi-extrusion printers are not supported", container.getId())
|
UM.Logger.log("d", "Not attaching MachineSettingsAction to %s; Multi-extrusion printers are not supported", container.getId())
|
||||||
return
|
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())
|
UM.Application.getInstance().getMachineActionManager().addSupportedAction(container.getId(), self.getKey())
|
||||||
|
|
||||||
@ -78,7 +95,7 @@ class MachineSettingsAction(MachineAction):
|
|||||||
# Set the material container to a sane default
|
# Set the material container to a sane default
|
||||||
if material_container.getId() == "empty_material":
|
if material_container.getId() == "empty_material":
|
||||||
search_criteria = { "type": "material", "definition": "fdmprinter", "id": "*pla*" }
|
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:
|
if containers:
|
||||||
global_container_stack.replaceContainer(material_index, containers[0])
|
global_container_stack.replaceContainer(material_index, containers[0])
|
||||||
else:
|
else:
|
||||||
@ -87,7 +104,7 @@ class MachineSettingsAction(MachineAction):
|
|||||||
if "has_materials" in global_container_stack.getMetaData():
|
if "has_materials" in global_container_stack.getMetaData():
|
||||||
global_container_stack.removeMetaDataEntry("has_materials")
|
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)
|
global_container_stack.replaceContainer(material_index, empty_material)
|
||||||
|
|
||||||
UM.Application.getInstance().globalContainerStackChanged.emit()
|
UM.Application.getInstance().globalContainerStackChanged.emit()
|
@ -147,19 +147,40 @@ Cura.MachineAction
|
|||||||
|
|
||||||
ComboBox
|
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:
|
currentIndex:
|
||||||
{
|
{
|
||||||
var index = model.indexOf(machineGCodeFlavorProvider.properties.value);
|
var currentValue = machineGCodeFlavorProvider.properties.value;
|
||||||
if(index == -1)
|
var index = 0;
|
||||||
|
for(var i = 0; i < flavorModel.count; i++)
|
||||||
{
|
{
|
||||||
index = 0;
|
if(flavorModel.get(i).value == currentValue) {
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return index
|
return index
|
||||||
}
|
}
|
||||||
onActivated:
|
onActivated:
|
||||||
{
|
{
|
||||||
machineGCodeFlavorProvider.setPropertyValue("value", model[index]);
|
machineGCodeFlavorProvider.setPropertyValue("value", flavorModel.get(index).value);
|
||||||
manager.updateHasMaterialsMetadata();
|
manager.updateHasMaterialsMetadata();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,17 +294,20 @@ Cura.MachineAction
|
|||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@label", "Nozzle size")
|
text: catalog.i18nc("@label", "Nozzle size")
|
||||||
|
visible: !Cura.MachineManager.hasVariants
|
||||||
}
|
}
|
||||||
TextField
|
TextField
|
||||||
{
|
{
|
||||||
id: nozzleSizeField
|
id: nozzleSizeField
|
||||||
text: machineNozzleSizeProvider.properties.value
|
text: machineNozzleSizeProvider.properties.value
|
||||||
|
visible: !Cura.MachineManager.hasVariants
|
||||||
validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
|
validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
|
||||||
onEditingFinished: { machineNozzleSizeProvider.setPropertyValue("value", text) }
|
onEditingFinished: { machineNozzleSizeProvider.setPropertyValue("value", text) }
|
||||||
}
|
}
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@label", "mm")
|
text: catalog.i18nc("@label", "mm")
|
||||||
|
visible: !Cura.MachineManager.hasVariants
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -308,6 +332,8 @@ Cura.MachineAction
|
|||||||
id: machineStartGcodeField
|
id: machineStartGcodeField
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height - y
|
height: parent.height - y
|
||||||
|
font: UM.Theme.getFont("fixed")
|
||||||
|
wrapMode: TextEdit.NoWrap
|
||||||
text: machineStartGcodeProvider.properties.value
|
text: machineStartGcodeProvider.properties.value
|
||||||
onActiveFocusChanged:
|
onActiveFocusChanged:
|
||||||
{
|
{
|
||||||
@ -330,6 +356,8 @@ Cura.MachineAction
|
|||||||
id: machineEndGcodeField
|
id: machineEndGcodeField
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height - y
|
height: parent.height - y
|
||||||
|
font: UM.Theme.getFont("fixed")
|
||||||
|
wrapMode: TextEdit.NoWrap
|
||||||
text: machineEndGcodeProvider.properties.value
|
text: machineEndGcodeProvider.properties.value
|
||||||
onActiveFocusChanged:
|
onActiveFocusChanged:
|
||||||
{
|
{
|
||||||
@ -377,7 +405,7 @@ Cura.MachineAction
|
|||||||
containerStackId: Cura.MachineManager.activeMachineId
|
containerStackId: Cura.MachineManager.activeMachineId
|
||||||
key: "machine_width"
|
key: "machine_width"
|
||||||
watchedProperties: [ "value" ]
|
watchedProperties: [ "value" ]
|
||||||
storeIndex: 4
|
storeIndex: manager.containerIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
@ -387,7 +415,7 @@ Cura.MachineAction
|
|||||||
containerStackId: Cura.MachineManager.activeMachineId
|
containerStackId: Cura.MachineManager.activeMachineId
|
||||||
key: "machine_depth"
|
key: "machine_depth"
|
||||||
watchedProperties: [ "value" ]
|
watchedProperties: [ "value" ]
|
||||||
storeIndex: 4
|
storeIndex: manager.containerIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
@ -397,7 +425,7 @@ Cura.MachineAction
|
|||||||
containerStackId: Cura.MachineManager.activeMachineId
|
containerStackId: Cura.MachineManager.activeMachineId
|
||||||
key: "machine_height"
|
key: "machine_height"
|
||||||
watchedProperties: [ "value" ]
|
watchedProperties: [ "value" ]
|
||||||
storeIndex: 4
|
storeIndex: manager.containerIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
@ -407,7 +435,7 @@ Cura.MachineAction
|
|||||||
containerStackId: Cura.MachineManager.activeMachineId
|
containerStackId: Cura.MachineManager.activeMachineId
|
||||||
key: "machine_heated_bed"
|
key: "machine_heated_bed"
|
||||||
watchedProperties: [ "value" ]
|
watchedProperties: [ "value" ]
|
||||||
storeIndex: 4
|
storeIndex: manager.containerIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
@ -417,7 +445,7 @@ Cura.MachineAction
|
|||||||
containerStackId: Cura.MachineManager.activeMachineId
|
containerStackId: Cura.MachineManager.activeMachineId
|
||||||
key: "machine_center_is_zero"
|
key: "machine_center_is_zero"
|
||||||
watchedProperties: [ "value" ]
|
watchedProperties: [ "value" ]
|
||||||
storeIndex: 4
|
storeIndex: manager.containerIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
@ -426,8 +454,8 @@ Cura.MachineAction
|
|||||||
|
|
||||||
containerStackId: Cura.MachineManager.activeMachineId
|
containerStackId: Cura.MachineManager.activeMachineId
|
||||||
key: "machine_gcode_flavor"
|
key: "machine_gcode_flavor"
|
||||||
watchedProperties: [ "value" ]
|
watchedProperties: [ "value", "options" ]
|
||||||
storeIndex: 4
|
storeIndex: manager.containerIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
@ -437,7 +465,7 @@ Cura.MachineAction
|
|||||||
containerStackId: Cura.MachineManager.activeMachineId
|
containerStackId: Cura.MachineManager.activeMachineId
|
||||||
key: "machine_nozzle_size"
|
key: "machine_nozzle_size"
|
||||||
watchedProperties: [ "value" ]
|
watchedProperties: [ "value" ]
|
||||||
storeIndex: 4
|
storeIndex: manager.containerIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
@ -447,7 +475,7 @@ Cura.MachineAction
|
|||||||
containerStackId: Cura.MachineManager.activeMachineId
|
containerStackId: Cura.MachineManager.activeMachineId
|
||||||
key: "gantry_height"
|
key: "gantry_height"
|
||||||
watchedProperties: [ "value" ]
|
watchedProperties: [ "value" ]
|
||||||
storeIndex: 4
|
storeIndex: manager.containerIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
@ -457,7 +485,7 @@ Cura.MachineAction
|
|||||||
containerStackId: Cura.MachineManager.activeMachineId
|
containerStackId: Cura.MachineManager.activeMachineId
|
||||||
key: "machine_head_with_fans_polygon"
|
key: "machine_head_with_fans_polygon"
|
||||||
watchedProperties: [ "value" ]
|
watchedProperties: [ "value" ]
|
||||||
storeIndex: 4
|
storeIndex: manager.containerIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -468,7 +496,7 @@ Cura.MachineAction
|
|||||||
containerStackId: Cura.MachineManager.activeMachineId
|
containerStackId: Cura.MachineManager.activeMachineId
|
||||||
key: "machine_start_gcode"
|
key: "machine_start_gcode"
|
||||||
watchedProperties: [ "value" ]
|
watchedProperties: [ "value" ]
|
||||||
storeIndex: 4
|
storeIndex: manager.containerIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
@ -478,7 +506,7 @@ Cura.MachineAction
|
|||||||
containerStackId: Cura.MachineManager.activeMachineId
|
containerStackId: Cura.MachineManager.activeMachineId
|
||||||
key: "machine_end_gcode"
|
key: "machine_end_gcode"
|
||||||
watchedProperties: [ "value" ]
|
watchedProperties: [ "value" ]
|
||||||
storeIndex: 4
|
storeIndex: manager.containerIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -27,19 +27,23 @@ class UMOUpgradeSelection(MachineAction):
|
|||||||
def setHeatedBed(self, heated_bed = True):
|
def setHeatedBed(self, heated_bed = True):
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if global_container_stack:
|
if global_container_stack:
|
||||||
variant = global_container_stack.findContainer({"type": "variant"})
|
# Make sure there is a definition_changes container to store the machine settings
|
||||||
if variant:
|
definition_changes_container = global_container_stack.findContainer({"type": "definition_changes"})
|
||||||
if variant.getId() == "empty_variant":
|
if not definition_changes_container:
|
||||||
variant_index = global_container_stack.getContainerIndex(variant)
|
definition_changes_container = self._createDefinitionChangesContainer(global_container_stack)
|
||||||
variant = self._createVariant(global_container_stack, variant_index)
|
|
||||||
variant.setProperty("machine_heated_bed", "value", heated_bed)
|
|
||||||
self.heatedBedChanged.emit()
|
|
||||||
|
|
||||||
def _createVariant(self, global_container_stack, variant_index):
|
definition_changes_container.setProperty("machine_heated_bed", "value", heated_bed)
|
||||||
# Create and switch to a variant to store the settings in
|
self.heatedBedChanged.emit()
|
||||||
new_variant = UM.Settings.InstanceContainer(global_container_stack.getName() + "_variant")
|
|
||||||
new_variant.addMetaDataEntry("type", "variant")
|
def _createDefinitionChangesContainer(self, global_container_stack):
|
||||||
new_variant.setDefinition(global_container_stack.getBottom())
|
# Create a definition_changes container to store the settings in and add it to the stack
|
||||||
UM.Settings.ContainerRegistry.getInstance().addContainer(new_variant)
|
definition_changes_container = UM.Settings.InstanceContainer(global_container_stack.getName() + "_settings")
|
||||||
global_container_stack.replaceContainer(variant_index, new_variant)
|
definition = global_container_stack.getBottom()
|
||||||
return new_variant
|
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