Merge branch 'master' of github.com:Ultimaker/Cura

This commit is contained in:
Jaime van Kessel 2016-09-28 15:20:59 +02:00
commit 7b7c161d93
6 changed files with 76 additions and 13 deletions

View file

@ -502,6 +502,7 @@ class CuraApplication(QtApplication):
qmlRegisterType(cura.Settings.ExtrudersModel, "Cura", 1, 0, "ExtrudersModel")
qmlRegisterType(cura.Settings.ContainerSettingsModel, "Cura", 1, 0, "ContainerSettingsModel")
qmlRegisterType(cura.Settings.ProfilesModel, "Cura", 1, 0, "ProfilesModel")
qmlRegisterType(cura.Settings.MaterialSettingsVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler")
qmlRegisterType(cura.Settings.QualitySettingsModel, "Cura", 1, 0, "QualitySettingsModel")

View file

@ -130,7 +130,12 @@ class PrintInformation(QObject):
## Created an acronymn-like abbreviated machine name from the currently active machine name
# Called each time the global stack is switched
def _setAbbreviatedMachineName(self):
global_stack_name = Application.getInstance().getGlobalContainerStack().getName()
global_container_stack = Application.getInstance().getGlobalContainerStack()
if not global_container_stack:
self._abbr_machine = ""
return
global_stack_name = global_container_stack.getName()
split_name = global_stack_name.split(" ")
abbr_machine = ""
for word in split_name:

View file

@ -144,17 +144,18 @@ class CuraContainerRegistry(ContainerRegistry):
self._configureProfile(profile, name_seed)
return { "status": "ok", "message": catalog.i18nc("@info:status", "Successfully imported profile {0}", profile.getName()) }
else:
new_name = self.createUniqueName("quality_changes", "", name_seed, catalog.i18nc("@label", "Custom profile"))
for profile in profile_or_list:
extruder_id = profile.getMetaDataEntry("extruder")
if extruder_id:
profile_name = "%s_%s" % (extruder_id, name_seed)
else:
profile_name = name_seed
new_name = self.createUniqueName("quality_changes", "", profile_name, catalog.i18nc("@label", "Custom profile"))
profile.setDirty(True) # Ensure the profiles are correctly saved
self._configureProfile(profile, name_seed)
self._configureProfile(profile, profile_name)
profile.setName(new_name)
if len(profile_or_list) == 1:
return {"status": "ok", "message": catalog.i18nc("@info:status", "Successfully imported profile {0}", profile_or_list[0].getName())}
else:
profile_names = ", ".join([profile.getName() for profile in profile_or_list])
return { "status": "ok", "message": catalog.i18nc("@info:status", "Successfully imported profiles {0}", profile_names) }
return {"status": "ok", "message": catalog.i18nc("@info:status", "Successfully imported profile {0}", profile_or_list[0].getName())}
#If it hasn't returned by now, none of the plugins loaded the profile successfully.
return { "status": "error", "message": catalog.i18nc("@info:status", "Profile {0} has an unknown file type.", file_name)}

View file

@ -0,0 +1,58 @@
# Copyright (c) 2016 Ultimaker B.V.
# Uranium is released under the terms of the AGPLv3 or higher.
from UM.Application import Application
from UM.Settings.Models.InstanceContainersModel import InstanceContainersModel
from UM.Settings.ContainerRegistry import ContainerRegistry
from cura.Settings.ExtruderManager import ExtruderManager
## QML Model for listing the current list of valid quality profiles.
#
class ProfilesModel(InstanceContainersModel):
def __init__(self, parent = None):
super().__init__(parent)
## Fetch the list of containers to display.
#
# See UM.Settings.Models.InstanceContainersModel._fetchInstanceContainers().
def _fetchInstanceContainers(self):
global_container_stack = Application.getInstance().getGlobalContainerStack()
global_machine_definition = global_container_stack.getBottom()
extruder_stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
if extruder_stacks:
# Multi-extruder machine detected.
# Determine the common set of quality types which can be
# applied to all of the materials for this machine.
quality_type_dict = self.__fetchQualityTypeDictForStack(global_container_stack, global_machine_definition)
common_quality_types = set(quality_type_dict.keys())
for stack in extruder_stacks[1:]:
next_quality_type_dict = self.__fetchQualityTypeDictForStack(stack, global_machine_definition)
common_quality_types.intersection_update(set(next_quality_type_dict.keys()))
return [quality_type_dict[quality_type] for quality_type in common_quality_types]
else:
# Machine with one extruder.
quality_type_dict = self.__fetchQualityTypeDictForStack(global_container_stack, global_machine_definition)
return list(quality_type_dict.values())
return []
def __fetchQualityTypeDictForStack(self, stack, global_machine_definition):
criteria = {"type": "quality" }
if global_machine_definition.getMetaDataEntry("has_machine_quality", False):
criteria["definition"] = global_machine_definition.getId()
if global_machine_definition.getMetaDataEntry("has_materials", False):
material = stack.findContainer(type="material")
criteria["material"] = material.getId()
else:
criteria["definition"] = "fdmprinter"
qualities = ContainerRegistry.getInstance().findInstanceContainers(**criteria)
quality_type_dict = {}
for quality in qualities:
quality_type_dict[quality.getMetaDataEntry("quality_type")] = quality
return quality_type_dict

View file

@ -11,4 +11,5 @@ from .MachineManager import MachineManager
from .MaterialSettingsVisibilityHandler import MaterialSettingsVisibilityHandler
from .SettingOverrideDecorator import SettingOverrideDecorator
from .QualitySettingsModel import QualitySettingsModel
from .SettingInheritanceManager import SettingInheritanceManager
from .SettingInheritanceManager import SettingInheritanceManager
from .ProfilesModel import ProfilesModel

View file

@ -13,10 +13,7 @@ Menu
Instantiator
{
model: UM.InstanceContainersModel
{
filter: menu.getFilter({ "type": "quality" });
}
model: Cura.ProfilesModel { }
MenuItem
{