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

This commit is contained in:
Jaime van Kessel 2016-09-15 09:43:11 +02:00
commit a5e6742cfa
10 changed files with 94 additions and 31 deletions

View file

@ -46,6 +46,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
self.addRoleName(self.IndexRole, "index")
self._add_global = False
self._simple_names = False
self._active_extruder_stack = None
@ -70,6 +71,21 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
def addGlobal(self):
return self._add_global
## Set the simpleNames property.
def setSimpleNames(self, simple_names):
if simple_names != self._simple_names:
self._simple_names = simple_names
self.simpleNamesChanged.emit()
self._updateExtruders()
## Emitted when the simpleNames property changes.
simpleNamesChanged = pyqtSignal()
## Whether or not the model should show all definitions regardless of visibility.
@pyqtProperty(bool, fset = setSimpleNames, notify = simpleNamesChanged)
def simpleNames(self):
return self._simple_names
def _onActiveExtruderChanged(self):
manager = ExtruderManager.getInstance()
active_extruder_stack = manager.getActiveExtruderStack()
@ -119,7 +135,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
for extruder in manager.getMachineExtruders(global_container_stack.getId()):
extruder_name = extruder.getName()
material = extruder.findContainer({ "type": "material" })
if material:
if material and not self._simple_names:
extruder_name = "%s (%s)" % (material.getName(), extruder_name)
position = extruder.getMetaDataEntry("position", default = "0") # Get the position
try:

View file

@ -124,22 +124,6 @@ class MachineManager(QObject):
else:
Logger.log("w", "No variant found for printer definition %s with id %s" % (self._global_container_stack.getBottom().getId(), hotend_id))
def _autoUpdateHotends(self):
extruder_manager = ExtruderManager.getInstance()
for position in self._auto_hotends_changed:
hotend_id = self._auto_hotends_changed[position]
old_index = extruder_manager.activeExtruderIndex
if old_index != int(position):
extruder_manager.setActiveExtruderIndex(int(position))
else:
old_index = None
Logger.log("d", "Setting hotend variant of hotend %s to %s" % (position, hotend_id))
self.setActiveVariant(hotend_id)
if old_index is not None:
extruder_manager.setActiveExtruderIndex(old_index)
def _onMaterialIdChanged(self, index, material_id):
if not self._global_container_stack:
return
@ -189,6 +173,22 @@ class MachineManager(QObject):
if old_index is not None:
extruder_manager.setActiveExtruderIndex(old_index)
def _autoUpdateHotends(self):
extruder_manager = ExtruderManager.getInstance()
for position in self._auto_hotends_changed:
hotend_id = self._auto_hotends_changed[position]
old_index = extruder_manager.activeExtruderIndex
if old_index != int(position):
extruder_manager.setActiveExtruderIndex(int(position))
else:
old_index = None
Logger.log("d", "Setting hotend variant of hotend %s to %s" % (position, hotend_id))
self.setActiveVariant(hotend_id)
if old_index is not None:
extruder_manager.setActiveExtruderIndex(old_index)
def _onGlobalContainerChanged(self):
if self._global_container_stack:
self._global_container_stack.nameChanged.disconnect(self._onMachineNameChanged)

View file

@ -80,7 +80,7 @@ class Profile:
import VersionUpgrade21to22 # Import here to prevent circular dependencies.
if self._name == "Current settings":
return None #Can't upgrade these, because the new current profile needs to specify the definition ID and the old file only had the machine instance, not the definition.
return None, None #Can't upgrade these, because the new current profile needs to specify the definition ID and the old file only had the machine instance, not the definition.
config = configparser.ConfigParser(interpolation = None)

View file

@ -118,6 +118,12 @@ _profile_translations = {
"tpu_0.6_fast": "um2p_tpu_0.6_fast"
}
## Settings that are no longer in the new version.
_removed_settings = {
"fill_perimeter_gaps",
"support_area_smoothing"
}
## How to translate setting names from the old version to the new.
_setting_name_translations = {
"remove_overlapping_walls_0_enabled": "travel_compensate_overlapping_walls_0_enabled",
@ -385,7 +391,7 @@ class VersionUpgrade21to22(VersionUpgrade):
@staticmethod
def translateSettings(settings):
for key, value in settings.items():
if key == "fill_perimeter_gaps": #Setting is removed.
if key in _removed_settings:
del settings[key]
elif key == "retraction_combing": #Combing was made into an enum instead of a boolean.
settings[key] = "off" if (value == "False") else "all"

View file

@ -145,8 +145,8 @@ UM.MainWindow
title: model.name
visible: machineExtruderCount.properties.value > 1
NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.hasVariants }
MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.hasMaterials }
NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.hasVariants; extruderIndex: index }
MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.hasMaterials; extruderIndex: index }
ProfileMenu { title: catalog.i18nc("@title:menu", "&Profile"); }
MenuSeparator { }

View file

@ -12,11 +12,32 @@ Menu
id: menu
title: "Material"
property int extruderIndex: 0
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
MenuItem
{
id: automaticMaterial
text: catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg("[material_name]")
visible: false
text:
{
var materialName = Cura.MachineManager.printerOutputDevices[0].materialNames[extruderIndex];
return catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg(materialName);
}
visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].materialNames.length > extruderIndex
onTriggered:
{
var material_id = Cura.MachineManager.printerOutputDevices[0].materialIds[extruderIndex];
var items = materialsModel.items;
// materialsModel.find cannot be used because we need to look inside the metadata property of items
for(var i in items)
{
if (items[i]["metadata"]["GUID"] == material_id)
{
Cura.MachineManager.setActiveMaterial(items[i].id);
break;
}
}
}
}
MenuSeparator

View file

@ -12,11 +12,27 @@ Menu
id: menu
title: "Nozzle"
property int extruderIndex: 0
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
MenuItem
{
id: automaticNozzle
text: catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg("[nozzle_name]")
visible: false
text:
{
var nozzleName = Cura.MachineManager.printerOutputDevices[0].hotendIds[extruderIndex];
return catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg(nozzleName);
}
visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].hotendIds.length > extruderIndex
onTriggered:
{
var hotendId = Cura.MachineManager.printerOutputDevices[0].hotendIds[extruderIndex];
var itemIndex = nozzleInstantiator.model.find("name", hotendId);
if(itemIndex > -1)
{
Cura.MachineManager.setActiveVariant(nozzleInstantiator.model.getItem(itemIndex).id)
}
}
}
MenuSeparator
@ -26,6 +42,7 @@ Menu
Instantiator
{
id: nozzleInstantiator
model: UM.InstanceContainersModel
{
filter:

View file

@ -14,7 +14,6 @@ UM.ManagementPage
title: catalog.i18nc("@title:tab", "Profiles");
property var extrudersModel: Cura.ExtrudersModel{}
//Cura.ExtrudersModel { id: extrudersModel}
model: UM.InstanceContainersModel
{
@ -167,11 +166,11 @@ UM.ManagementPage
elide: Text.ElideRight
}
Row {
Flow {
id: currentSettingsActions
visible: currentItem && currentItem.id == Cura.MachineManager.activeQualityId
anchors.left: parent.left
anchors.right: parent.right
anchors.top: profileName.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").height

View file

@ -14,7 +14,11 @@ Column
id: printMonitor
property var connectedPrinter: printerConnected ? Cura.MachineManager.printerOutputDevices[0] : null
Cura.ExtrudersModel { id: extrudersModel }
Cura.ExtrudersModel
{
id: extrudersModel
simpleNames: true
}
Label
{

View file

@ -223,7 +223,7 @@ Column
anchors.left: parent.left
style: UM.Theme.styles.sidebar_header_button
menu: NozzleMenu { }
menu: NozzleMenu { extruderIndex: base.currentExtruderIndex }
}
ToolButton {
@ -251,7 +251,7 @@ Column
anchors.right: parent.right
style: UM.Theme.styles.sidebar_header_button
menu: MaterialMenu { }
menu: MaterialMenu { extruderIndex: base.currentExtruderIndex }
}
}
}