Merge pull request #3134 from Ultimaker/3.2

Fix for CURA-4789
This commit is contained in:
Ian Paschal 2018-01-15 14:41:23 +01:00 committed by GitHub
commit dac67ef2fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 92 additions and 74 deletions

View file

@ -805,6 +805,7 @@ class CuraApplication(QtApplication):
qmlRegisterUncreatableType(CuraApplication, "Cura", 1, 0, "ResourceTypes", "Just an Enum type") qmlRegisterUncreatableType(CuraApplication, "Cura", 1, 0, "ResourceTypes", "Just an Enum type")
qmlRegisterType(InstanceContainer, "Cura", 1, 0, "InstanceContainer")
qmlRegisterType(ExtrudersModel, "Cura", 1, 0, "ExtrudersModel") qmlRegisterType(ExtrudersModel, "Cura", 1, 0, "ExtrudersModel")
qmlRegisterType(ContainerSettingsModel, "Cura", 1, 0, "ContainerSettingsModel") qmlRegisterType(ContainerSettingsModel, "Cura", 1, 0, "ContainerSettingsModel")
qmlRegisterSingletonType(ProfilesModel, "Cura", 1, 0, "ProfilesModel", ProfilesModel.createProfilesModel) qmlRegisterSingletonType(ProfilesModel, "Cura", 1, 0, "ProfilesModel", ProfilesModel.createProfilesModel)
@ -1059,6 +1060,9 @@ class CuraApplication(QtApplication):
op.push() op.push()
Selection.clear() Selection.clear()
Logger.log("i", "Reseting print information")
self._print_information = PrintInformation.PrintInformation()
self.getCuraSceneController().setActiveBuildPlate(0) # Select first build plate self.getCuraSceneController().setActiveBuildPlate(0) # Select first build plate
## Reset all translation on nodes with mesh data. ## Reset all translation on nodes with mesh data.

View file

@ -136,6 +136,9 @@ class QualityManager:
if basic_materials: if basic_materials:
result = self._getFilteredContainersForStack(machine_definition, basic_materials, **criteria) result = self._getFilteredContainersForStack(machine_definition, basic_materials, **criteria)
empty_quality = ContainerRegistry.getInstance().findInstanceContainers(id = "empty_quality")[0]
result.append(empty_quality)
return result return result
## Find all quality changes for a machine. ## Find all quality changes for a machine.

View file

@ -36,6 +36,8 @@ class ProfilesModel(InstanceContainersModel):
Application.getInstance().getMachineManager().activeStackChanged.connect(self._update) Application.getInstance().getMachineManager().activeStackChanged.connect(self._update)
Application.getInstance().getMachineManager().activeMaterialChanged.connect(self._update) Application.getInstance().getMachineManager().activeMaterialChanged.connect(self._update)
self._empty_quality = ContainerRegistry.getInstance().findContainers(id = "empty_quality")[0]
# Factory function, used by QML # Factory function, used by QML
@staticmethod @staticmethod
def createProfilesModel(engine, js_engine): def createProfilesModel(engine, js_engine):
@ -72,11 +74,18 @@ class ProfilesModel(InstanceContainersModel):
# The actual list of quality profiles come from the first extruder in the extruder list. # The actual list of quality profiles come from the first extruder in the extruder list.
result = QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_container_stack, extruder_stacks) result = QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_container_stack, extruder_stacks)
# append empty quality if it's not there
if not any(q.getId() == self._empty_quality.getId() for q in result):
result.append(self._empty_quality)
# The usable quality types are set # The usable quality types are set
quality_type_set = set([x.getMetaDataEntry("quality_type") for x in result]) quality_type_set = set([x.getMetaDataEntry("quality_type") for x in result])
# Fetch all qualities available for this machine and the materials selected in extruders # Fetch all qualities available for this machine and the materials selected in extruders
all_qualities = QualityManager.getInstance().findAllQualitiesForMachineAndMaterials(global_stack_definition, materials) all_qualities = QualityManager.getInstance().findAllQualitiesForMachineAndMaterials(global_stack_definition, materials)
# append empty quality if it's not there
if not any(q.getId() == self._empty_quality.getId() for q in all_qualities):
all_qualities.append(self._empty_quality)
# If in the all qualities there is some of them that are not available due to incompatibility with materials # If in the all qualities there is some of them that are not available due to incompatibility with materials
# we also add it so that they will appear in the slide quality bar. However in recomputeItems will be marked as # we also add it so that they will appear in the slide quality bar. However in recomputeItems will be marked as
@ -85,12 +94,6 @@ class ProfilesModel(InstanceContainersModel):
if quality.getMetaDataEntry("quality_type") not in quality_type_set: if quality.getMetaDataEntry("quality_type") not in quality_type_set:
result.append(quality) result.append(quality)
# if still profiles are found, add a single empty_quality ("Not supported") instance to the drop down list
if len(result) == 0:
# If not qualities are found we dynamically create a not supported container for this machine + material combination
not_supported_container = ContainerRegistry.getInstance().findContainers(id = "empty_quality")[0]
result.append(not_supported_container)
return {item.getId(): item for item in result}, {} #Only return true profiles for now, no metadata. The quality manager is not able to get only metadata yet. return {item.getId(): item for item in result}, {} #Only return true profiles for now, no metadata. The quality manager is not able to get only metadata yet.
## Re-computes the items in this model, and adds the layer height role. ## Re-computes the items in this model, and adds the layer height role.
@ -114,7 +117,6 @@ class ProfilesModel(InstanceContainersModel):
# active machine and material, and later yield the right ones. # active machine and material, and later yield the right ones.
tmp_all_quality_items = OrderedDict() tmp_all_quality_items = OrderedDict()
for item in super()._recomputeItems(): for item in super()._recomputeItems():
profiles = container_registry.findContainersMetadata(id = item["id"]) profiles = container_registry.findContainersMetadata(id = item["id"])
if not profiles or "quality_type" not in profiles[0]: if not profiles or "quality_type" not in profiles[0]:
quality_type = "" quality_type = ""

View file

@ -42,5 +42,7 @@ class QualityAndUserProfilesModel(ProfilesModel):
qc.getMetaDataEntry("extruder") == active_extruder.definition.getId())} qc.getMetaDataEntry("extruder") == active_extruder.definition.getId())}
result = filtered_quality_changes result = filtered_quality_changes
result.update({q.getId():q for q in quality_list}) for q in quality_list:
if q.getId() != "empty_quality":
result[q.getId()] = q
return result, {} #Only return true profiles for now, no metadata. The quality manager is not able to get only metadata yet. return result, {} #Only return true profiles for now, no metadata. The quality manager is not able to get only metadata yet.

View file

@ -1,8 +1,6 @@
# Copyright (c) 2017 Ultimaker B.V. # Copyright (c) 2017 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
import collections
from PyQt5.QtCore import pyqtProperty, pyqtSignal, Qt from PyQt5.QtCore import pyqtProperty, pyqtSignal, Qt
from UM.Logger import Logger from UM.Logger import Logger
@ -42,6 +40,8 @@ class QualitySettingsModel(UM.Qt.ListModel.ListModel):
self.addRoleName(self.UserValueRole, "user_value") self.addRoleName(self.UserValueRole, "user_value")
self.addRoleName(self.CategoryRole, "category") self.addRoleName(self.CategoryRole, "category")
self._empty_quality = self._container_registry.findInstanceContainers(id = "empty_quality")[0]
def setExtruderId(self, extruder_id): def setExtruderId(self, extruder_id):
if extruder_id != self._extruder_id: if extruder_id != self._extruder_id:
self._extruder_id = extruder_id self._extruder_id = extruder_id
@ -107,6 +107,9 @@ class QualitySettingsModel(UM.Qt.ListModel.ListModel):
else: else:
quality_changes_container = containers[0] quality_changes_container = containers[0]
if quality_changes_container.getMetaDataEntry("quality_type") == "not_supported":
quality_container = self._empty_quality
else:
criteria = { criteria = {
"type": "quality", "type": "quality",
"quality_type": quality_changes_container.getMetaDataEntry("quality_type"), "quality_type": quality_changes_container.getMetaDataEntry("quality_type"),
@ -117,9 +120,14 @@ class QualitySettingsModel(UM.Qt.ListModel.ListModel):
if not quality_container: if not quality_container:
Logger.log("w", "Could not find a quality container matching quality changes %s", quality_changes_container.getId()) Logger.log("w", "Could not find a quality container matching quality changes %s", quality_changes_container.getId())
return return
quality_container = quality_container[0] quality_container = quality_container[0]
quality_type = quality_container.getMetaDataEntry("quality_type") quality_type = quality_container.getMetaDataEntry("quality_type")
if quality_type == "not_supported":
containers = []
else:
definition_id = Application.getInstance().getMachineManager().getQualityDefinitionId(quality_container.getDefinition()) definition_id = Application.getInstance().getMachineManager().getQualityDefinitionId(quality_container.getDefinition())
definition = quality_container.getDefinition() definition = quality_container.getDefinition()
@ -163,6 +171,9 @@ class QualitySettingsModel(UM.Qt.ListModel.ListModel):
return return
if quality_changes_container: if quality_changes_container:
if quality_type == "not_supported":
criteria = {"type": "quality_changes", "quality_type": quality_type, "name": quality_changes_container.getName()}
else:
criteria = {"type": "quality_changes", "quality_type": quality_type, "definition": definition_id, "name": quality_changes_container.getName()} criteria = {"type": "quality_changes", "quality_type": quality_type, "definition": definition_id, "name": quality_changes_container.getName()}
if self._extruder_definition_id != "": if self._extruder_definition_id != "":
extruder_definitions = self._container_registry.findDefinitionContainers(id = self._extruder_definition_id) extruder_definitions = self._container_registry.findDefinitionContainers(id = self._extruder_definition_id)
@ -177,7 +188,6 @@ class QualitySettingsModel(UM.Qt.ListModel.ListModel):
containers.extend(changes) containers.extend(changes)
global_container_stack = Application.getInstance().getGlobalContainerStack() global_container_stack = Application.getInstance().getGlobalContainerStack()
is_multi_extrusion = global_container_stack.getProperty("machine_extruder_count", "value") > 1
current_category = "" current_category = ""
for definition in definition_container.findDefinitions(): for definition in definition_container.findDefinitions():
@ -213,7 +223,6 @@ class QualitySettingsModel(UM.Qt.ListModel.ListModel):
if profile_value is None and user_value is None: if profile_value is None and user_value is None:
continue continue
if is_multi_extrusion:
settable_per_extruder = global_container_stack.getProperty(definition.key, "settable_per_extruder") settable_per_extruder = global_container_stack.getProperty(definition.key, "settable_per_extruder")
# If a setting is not settable per extruder (global) and we're looking at an extruder tab, don't show this value. # If a setting is not settable per extruder (global) and we're looking at an extruder tab, don't show this value.
if self._extruder_id != "" and not settable_per_extruder: if self._extruder_id != "" and not settable_per_extruder:

View file

@ -213,8 +213,8 @@ UM.ManagementPage
ProfileTab ProfileTab
{ {
title: catalog.i18nc("@title:tab", "Global Settings"); title: catalog.i18nc("@title:tab", "Global Settings");
quality: base.currentItem != null ? base.currentItem.id : ""; quality: Cura.MachineManager.activeMachine.qualityChanges.id
material: Cura.MachineManager.allActiveMaterialIds[Cura.MachineManager.activeMachineId] material: Cura.MachineManager.activeMachine.material.id
} }
Repeater Repeater

View file

@ -63,11 +63,9 @@ Item
menu: ProfileMenu { } menu: ProfileMenu { }
function generateActiveQualityText () { function generateActiveQualityText () {
var result = catalog.i18nc("@", "No Profile Available") // default text
if (Cura.MachineManager.isActiveQualitySupported ) {
result = Cura.MachineManager.activeQualityName result = Cura.MachineManager.activeQualityName
if (Cura.MachineManager.isActiveQualitySupported ) {
if (Cura.MachineManager.activeQualityLayerHeight > 0) { if (Cura.MachineManager.activeQualityLayerHeight > 0) {
result += " <font color=\"" + UM.Theme.getColor("text_detail") + "\">" result += " <font color=\"" + UM.Theme.getColor("text_detail") + "\">"
result += " - " result += " - "