Merge branch 'master' into CS-234_network_plugin_code_quality

This commit is contained in:
ChrisTerBeke 2019-08-02 12:44:56 +02:00
commit 92d07ddb71
17 changed files with 69 additions and 54 deletions

View File

@ -127,7 +127,7 @@ class MachineErrorChecker(QObject):
# Populate the (stack, key) tuples to check
self._stacks_and_keys_to_check = deque()
for stack in [global_stack] + list(global_stack.extruders.values()):
for stack in global_stack.extruders.values():
for key in stack.getAllKeys():
self._stacks_and_keys_to_check.append((stack, key))

View File

@ -85,7 +85,14 @@ class VariantManager:
if variant_definition not in self._machine_to_buildplate_dict_map:
self._machine_to_buildplate_dict_map[variant_definition] = OrderedDict()
variant_container = self._container_registry.findContainers(type = "variant", id = variant_metadata["id"])[0]
try:
variant_container = self._container_registry.findContainers(type = "variant", id = variant_metadata["id"])[0]
except IndexError as e:
# It still needs to break, but we want to know what variant ID made it break.
msg = "Unable to find build plate variant with the id [%s]" % variant_metadata["id"]
Logger.logException("e", msg)
raise IndexError(msg)
buildplate_type = variant_container.getProperty("machine_buildplate_type", "value")
if buildplate_type not in self._machine_to_buildplate_dict_map[variant_definition]:
self._machine_to_variant_dict_map[variant_definition][buildplate_type] = dict()

View File

@ -129,8 +129,9 @@ class CuraStackBuilder:
extruder_definition = registry.findDefinitionContainers(id = extruder_definition_id)[0]
except IndexError as e:
# It still needs to break, but we want to know what extruder ID made it break.
Logger.log("e", "Unable to find extruder with the id %s", extruder_definition_id)
raise e
msg = "Unable to find extruder definition with the id [%s]" % extruder_definition_id
Logger.logException("e", msg)
raise IndexError(msg)
# get material container for extruders
material_container = application.empty_material_container

View File

@ -381,7 +381,13 @@ class ExtruderManager(QObject):
elif extruder_stack_0.definition.getId() != expected_extruder_definition_0_id:
Logger.log("e", "Single extruder printer [{printer}] expected extruder [{expected}], but got [{got}]. I'm making it [{expected}].".format(
printer = global_stack.getId(), expected = expected_extruder_definition_0_id, got = extruder_stack_0.definition.getId()))
extruder_definition = container_registry.findDefinitionContainers(id = expected_extruder_definition_0_id)[0]
try:
extruder_definition = container_registry.findDefinitionContainers(id = expected_extruder_definition_0_id)[0]
except IndexError as e:
# It still needs to break, but we want to know what extruder ID made it break.
msg = "Unable to find extruder definition with the id [%s]" % expected_extruder_definition_0_id
Logger.logException("e", msg)
raise IndexError(msg)
extruder_stack_0.definition = extruder_definition
## Get all extruder values for a certain setting.

View File

@ -1,15 +1,16 @@
# Copyright (c) 2018 Ultimaker B.V.
# Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from ..Script import Script
from UM.Application import Application #To get the current printer's settings.
from typing import List, Tuple
class PauseAtHeight(Script):
def __init__(self):
def __init__(self) -> None:
super().__init__()
def getSettingDataString(self):
def getSettingDataString(self) -> str:
return """{
"name": "Pause at height",
"key": "PauseAtHeight",
@ -113,11 +114,9 @@ class PauseAtHeight(Script):
}
}"""
def getNextXY(self, layer: str):
"""
Get the X and Y values for a layer (will be used to get X and Y of
the layer after the pause
"""
## Get the X and Y values for a layer (will be used to get X and Y of the
# layer after the pause).
def getNextXY(self, layer: str) -> Tuple[float, float]:
lines = layer.split("\n")
for line in lines:
if self.getValue(line, "X") is not None and self.getValue(line, "Y") is not None:
@ -126,8 +125,10 @@ class PauseAtHeight(Script):
return x, y
return 0, 0
def execute(self, data: list):
"""data is a list. Each index contains a layer"""
## Inserts the pause commands.
# \param data: List of layers.
# \return New list of layers.
def execute(self, data: List[str]) -> List[str]:
pause_at = self.getSettingValueByKey("pause_at")
pause_height = self.getSettingValueByKey("pause_height")
pause_layer = self.getSettingValueByKey("pause_layer")

View File

@ -127,6 +127,8 @@ class SliceInfo(QObject, Extension):
data["active_mode"] = "custom"
data["camera_view"] = application.getPreferences().getValue("general/camera_perspective_mode")
if data["camera_view"] == "orthographic":
data["camera_view"] = "orthogonal" #The database still only recognises the old name "orthogonal".
definition_changes = global_stack.definitionChanges
machine_settings_changed_by_user = False

View File

@ -196,8 +196,9 @@ _quality_changes_to_creality_base = {
"creality_cr10_extruder_0",
"creality_cr10s4_extruder_0",
"creality_cr10s5_extruder_0",
"creality_ender3_extruder_0"
"creality_ender3_extruder_0",
"creality_cr10",
"creality_cr10s",
"creality_cr10s4",
"creality_cr10s5",
"creality_ender3",

View File

@ -39,6 +39,17 @@ class VersionUpgrade42to43(VersionUpgrade):
setting_version = int(parser.get("metadata", "setting_version", fallback = "0"))
return format_version * 1000000 + setting_version
def upgradePreferences(self, serialized: str, filename: str):
parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized)
if "camera_perspective_mode" in parser["general"] and parser["general"]["camera_perspective_mode"] == "orthogonal":
parser["general"]["camera_perspective_mode"] = "orthographic"
result = io.StringIO()
parser.write(result)
return [filename], [result.getvalue()]
## Upgrades instance containers to have the new version
# number.
#

View File

@ -14,6 +14,7 @@ def getMetaData() -> Dict[str, Any]:
return {
"version_upgrade": {
# From To Upgrade function
("preferences", 6000008): ("preferences", 6000009, upgrade.upgradePreferences),
("machine_stack", 4000008): ("machine_stack", 4000009, upgrade.upgradeStack),
("extruder_train", 4000008): ("extruder_train", 4000009, upgrade.upgradeStack),
("definition_changes", 4000008): ("definition_changes", 4000009, upgrade.upgradeInstanceContainer),
@ -22,6 +23,10 @@ def getMetaData() -> Dict[str, Any]:
("user", 4000008): ("user", 4000009, upgrade.upgradeInstanceContainer),
},
"sources": {
"preferences": {
"get_version": upgrade.getCfgVersion,
"location": {"."}
},
"machine_stack": {
"get_version": upgrade.getCfgVersion,
"location": {"./machine_instances"}

View File

@ -9,7 +9,7 @@
"machine_max_feedrate_x": { "value": 500 },
"machine_max_feedrate_y": { "value": 500 },
"machine_max_feedrate_z": { "value": 5 },
"machine_max_feedrate_z": { "value": 10 },
"machine_max_feedrate_e": { "value": 50 },
"machine_max_acceleration_x": { "value": 500 },

View File

@ -1326,7 +1326,7 @@ msgstr "Nascondi o esponi giunzione"
#: fdmprinter.def.json
msgctxt "z_seam_corner option z_seam_corner_weighted"
msgid "Smart Hiding"
msgstr "Smart Hiding"
msgstr "Occultamento intelligente"
#: fdmprinter.def.json
msgctxt "z_seam_relative label"

View File

@ -31,6 +31,7 @@ Menu
return Cura.MachineManager.activeVariantNames[extruderIndex] == model.hotend_name
}
exclusiveGroup: group
onTriggered: {
Cura.MachineManager.setVariant(menu.extruderIndex, model.container_node);
}

View File

@ -15,15 +15,10 @@ Menu
PrinterMenu { title: catalog.i18nc("@title:menu menubar:settings", "&Printer") }
property var activeMachine: Cura.MachineManager.activeMachine
onAboutToShow: extruderInstantiator.active = true
onAboutToHide: extruderInstantiator.active = false
Instantiator
{
id: extruderInstantiator
model: activeMachine == null ? null : activeMachine.extruderList
active: false
asynchronous: true
Menu
{
title: modelData.name
@ -39,41 +34,20 @@ Menu
MenuItem
{
text: catalog.i18nc("@action:inmenu", "Set as Active Extruder")
// HACK: Instead of directly binding to the onTriggered handle, we have to use this workaround.
// I've narrowed it down to it being an issue with the instantiator (removing that makes the
// onTriggered work directly again).
Component.onCompleted:
{
var index = model.index
triggered.connect(function(){Cura.ExtruderManager.setActiveExtruderIndex(index)})
}
onTriggered: Cura.ExtruderManager.setActiveExtruderIndex(model.index)
}
MenuItem
{
text: catalog.i18nc("@action:inmenu", "Enable Extruder")
// HACK: Instead of directly binding to the onTriggered handle, we have to use this workaround.
// I've narrowed it down to it being an issue with the instantiator (removing that makes the
// onTriggered work directly again).
Component.onCompleted:
{
var index = model.index
triggered.connect(function(){Cura.MachineManager.setExtruderEnabled(index, true)})
}
onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, true)
visible: !Cura.MachineManager.getExtruder(model.index).isEnabled
}
MenuItem
{
text: catalog.i18nc("@action:inmenu", "Disable Extruder")
// HACK: Instead of directly binding to the onTriggered handle, we have to use this workaround.
// I've narrowed it down to it being an issue with the instantiator (removing that makes the
// onTriggered work directly again).
Component.onCompleted:
{
var index = model.index
triggered.connect(function(){Cura.MachineManager.setExtruderEnabled(index, false)})
}
onTriggered: Cura.MachineManager.setExtruderEnabled(index, false)
visible: Cura.MachineManager.getExtruder(model.index).isEnabled
enabled: Cura.MachineManager.numberExtrudersEnabled > 1
}

View File

@ -58,11 +58,11 @@ Menu
{
text: catalog.i18nc("@action:inmenu menubar:view", "Orthographic")
checkable: true
checked: cameraViewMenu.cameraMode == "orthogonal"
checked: cameraViewMenu.cameraMode == "orthographic"
onTriggered:
{
UM.Preferences.setValue("general/camera_perspective_mode", "orthogonal")
checked = cameraViewMenu.cameraMode == "orthogonal"
UM.Preferences.setValue("general/camera_perspective_mode", "orthographic")
checked = cameraViewMenu.cameraMode == "orthographic"
}
exclusiveGroup: group
}

View File

@ -158,7 +158,7 @@ UM.PreferencesPage
append({ text: "日本語", code: "ja_JP" })
append({ text: "한국어", code: "ko_KR" })
append({ text: "Nederlands", code: "nl_NL" })
append({ text: "Polski", code: "pl_PL" })
//Polish is disabled for being incomplete: append({ text: "Polski", code: "pl_PL" })
append({ text: "Português do Brasil", code: "pt_BR" })
append({ text: "Português", code: "pt_PT" })
append({ text: "Русский", code: "ru_RU" })
@ -368,7 +368,7 @@ UM.PreferencesPage
{
width: childrenRect.width;
height: childrenRect.height;
text: zoomToMouseCheckbox.enabled ? catalog.i18nc("@info:tooltip", "Should zooming move in the direction of the mouse?") : catalog.i18nc("@info:tooltip", "Zooming towards the mouse is not supported in the orthogonal perspective.")
text: zoomToMouseCheckbox.enabled ? catalog.i18nc("@info:tooltip", "Should zooming move in the direction of the mouse?") : catalog.i18nc("@info:tooltip", "Zooming towards the mouse is not supported in the orthographic perspective.")
CheckBox
{
@ -389,7 +389,7 @@ UM.PreferencesPage
{
return;
}
zoomToMouseCheckbox.enabled = UM.Preferences.getValue("general/camera_perspective_mode") !== "orthogonal";
zoomToMouseCheckbox.enabled = UM.Preferences.getValue("general/camera_perspective_mode") !== "orthographic";
zoomToMouseCheckbox.checked = boolCheck(UM.Preferences.getValue("view/zoom_to_mouse")) && zoomToMouseCheckbox.enabled;
}
}
@ -481,7 +481,7 @@ UM.PreferencesPage
Component.onCompleted: {
append({ text: catalog.i18n("Perspective"), code: "perspective" })
append({ text: catalog.i18n("Orthogonal"), code: "orthogonal" })
append({ text: catalog.i18n("Orthographic"), code: "orthographic" })
}
}

View File

@ -102,6 +102,7 @@ Item
}
}
}
base.currentItem = null
return false
}

View File

@ -58,6 +58,11 @@ Item
{
forceActiveFocus()
materialDetailsPanel.currentItem = currentItem
// CURA-6679 If the current item is gone after the model update, reset the current item to the active material.
if (currentItem == null)
{
resetExpandedActiveMaterial()
}
}
// Main layout