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

* 'master' of github.com:ultimaker/Cura:
  Determine readonly state from location in filesystem instead of a metadata property
  Change focus upon extruder switch
  Fix extruder number attached to extruders
  Fix duplicating the first item on the Profiles page
  Fix spelling
  Document setActiveExtruderIndex
  Inheritance button now works if instance containers contain functions
  JSON cleanup: removed settable_per_x when they were obvious and default (CURA-1560)
  feat: use settable_per_[mesh|extruder|meshgroup|globally] instead of global_only (CURA-1560)
  JSON feat: replaced global_only with four properties settable_per_[mesh|extruder|meshgroup] and settable_globally for fdmextruder settings (CURA-1558)
  JSON feat: replaced global_only with four properties settable_per_[mesh|extruder|meshgroup] and settable_globally (CURA-1558)
This commit is contained in:
Arjen Hiemstra 2016-06-09 13:31:08 +02:00
commit 627d5e3c0d
51 changed files with 618 additions and 327 deletions

View File

@ -93,7 +93,10 @@ class CuraApplication(QtApplication):
self._open_file_queue = [] # Files to open when plug-ins are loaded.
# Need to do this before ContainerRegistry tries to load the machines
SettingDefinition.addSupportedProperty("global_only", DefinitionPropertyType.Function, default = False)
SettingDefinition.addSupportedProperty("settable_per_mesh", DefinitionPropertyType.Any, default = True)
SettingDefinition.addSupportedProperty("settable_per_extruder", DefinitionPropertyType.Any, default = True)
SettingDefinition.addSupportedProperty("settable_per_meshgroup", DefinitionPropertyType.Any, default = True)
SettingDefinition.addSupportedProperty("settable_globally", DefinitionPropertyType.Any, default = True)
SettingDefinition.addSettingType("extruder", str, ast.literal_eval, UM.Settings.Validator)
super().__init__(name = "cura", version = CuraVersion, buildtype = CuraBuildType)

View File

@ -58,6 +58,9 @@ class ExtruderManager(QObject):
cls.__instance = ExtruderManager()
return cls.__instance
## Changes the active extruder by index.
#
# \param index The index of the new active extruder.
@pyqtSlot(int)
def setActiveExtruderIndex(self, index):
self._active_extruder_index = index

View File

@ -51,13 +51,18 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
global_container_stack = UM.Application.getInstance().getGlobalContainerStack()
if not global_container_stack:
return #There is no machine to get the extruders of.
for index, extruder in enumerate(manager.getMachineExtruders(global_container_stack.getBottom())):
for extruder in manager.getMachineExtruders(global_container_stack.getBottom()):
material = extruder.findContainer({ "type": "material" })
colour = material.getMetaDataEntry("color_code", default = "#FFFF00") if material else "#FFFF00"
position = extruder.getBottom().getMetaDataEntry("position", default = "0") #Position in the definition.
try:
position = int(position)
except ValueError: #Not a proper int.
position = -1
item = { #Construct an item with only the relevant information.
"name": extruder.getName(),
"colour": colour,
"index": index
"index": position
}
self.appendItem(item)
self.sort(lambda item: item["index"])

View File

@ -266,7 +266,7 @@ class MachineManagerModel(QObject):
containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id=container_id)
if not containers or not self._global_container_stack:
return True
return containers[0].getMetaDataEntry("read_only", False) == "True"
return containers[0].isReadOnly()
@pyqtSlot(result = str)
def convertUserContainerToQuality(self):
@ -288,7 +288,7 @@ class MachineManagerModel(QObject):
## Change type / id / name
new_quality_container.setMetaDataEntry("type", "quality")
new_quality_container.setMetaDataEntry("read_only", False)
new_quality_container.setReadOnly(False)
new_quality_container.setName(name)
new_quality_container._id = name
@ -310,7 +310,7 @@ class MachineManagerModel(QObject):
## Copy all values
new_container.deserialize(containers[0].serialize())
new_container.setMetaDataEntry("read_only", False)
new_container.setReadOnly(False)
new_container.setName(new_name)
new_container._id = new_name
UM.Settings.ContainerRegistry.getInstance().addContainer(new_container)

View File

@ -190,11 +190,11 @@ Item {
{
if(text != "")
{
listview.model.filter = {"global_only": false, "label": "*" + text}
listview.model.filter = {"settable_per_mesh": true, "label": "*" + text}
}
else
{
listview.model.filter = {"global_only": false}
listview.model.filter = {"settable_per_mesh": true}
}
}
}
@ -219,7 +219,7 @@ Item {
containerId: Cura.MachineManager.activeDefinitionId
filter:
{
"global_only": false
"settable_per_mesh": true
}
visibilityHandler: UM.SettingPreferenceVisibilityHandler {}
}

View File

@ -24,7 +24,11 @@
"description": "The extruder train used for printing. This is used in multi-extrusion.",
"type": "extruder",
"default_value": 0,
"minimum_value": "0"
"minimum_value": "0",
"settable_per_mesh": true,
"settable_per_extruder": false,
"settable_per_meshgroup": false,
"settable_globally": false
},
"machine_nozzle_offset_x":
{
@ -33,7 +37,10 @@
"type": "float",
"unit": "mm",
"default_value": 0,
"global_only": "True"
"settable_per_mesh": false,
"settable_per_extruder": true,
"settable_per_meshgroup": false,
"settable_globally": false
},
"machine_nozzle_offset_y":
{
@ -42,7 +49,10 @@
"type": "float",
"unit": "mm",
"default_value": 0,
"global_only": "True"
"settable_per_mesh": false,
"settable_per_extruder": true,
"settable_per_meshgroup": false,
"settable_globally": false
},
"machine_extruder_start_code":
{
@ -50,7 +60,10 @@
"description": "Start g-code to execute whenever turning the extruder on.",
"type": "str",
"default_value": "",
"global_only": "True"
"settable_per_mesh": false,
"settable_per_extruder": true,
"settable_per_meshgroup": false,
"settable_globally": false
},
"machine_extruder_start_pos_abs":
{
@ -58,7 +71,10 @@
"description": "Make the extruder starting position absolute rather than relative to the last-known location of the head.",
"type": "bool",
"default_value": false,
"global_only": "True"
"settable_per_mesh": false,
"settable_per_extruder": true,
"settable_per_meshgroup": false,
"settable_globally": false
},
"machine_extruder_start_pos_x":
{
@ -67,7 +83,10 @@
"type": "float",
"unit": "mm",
"default_value": 0,
"global_only": "True"
"settable_per_mesh": false,
"settable_per_extruder": true,
"settable_per_meshgroup": false,
"settable_globally": false
},
"machine_extruder_start_pos_y":
{
@ -76,7 +95,10 @@
"type": "float",
"unit": "mm",
"default_value": 0,
"global_only": "True"
"settable_per_mesh": false,
"settable_per_extruder": true,
"settable_per_meshgroup": false,
"settable_globally": false
},
"machine_extruder_end_code":
{
@ -84,7 +106,10 @@
"description": "End g-code to execute whenever turning the extruder off.",
"type": "str",
"default_value": "",
"global_only": "True"
"settable_per_mesh": false,
"settable_per_extruder": true,
"settable_per_meshgroup": false,
"settable_globally": false
},
"machine_extruder_end_pos_abs":
{
@ -92,7 +117,10 @@
"description": "Make the extruder ending position absolute rather than relative to the last-known location of the head.",
"type": "bool",
"default_value": false,
"global_only": "True"
"settable_per_mesh": false,
"settable_per_extruder": true,
"settable_per_meshgroup": false,
"settable_globally": false
},
"machine_extruder_end_pos_x":
{
@ -101,7 +129,10 @@
"type": "float",
"unit": "mm",
"default_value": 0,
"global_only": "True"
"settable_per_mesh": false,
"settable_per_extruder": true,
"settable_per_meshgroup": false,
"settable_globally": false
},
"machine_extruder_end_pos_y":
{
@ -110,7 +141,10 @@
"type": "float",
"unit": "mm",
"default_value": 0,
"global_only": "True"
"settable_per_mesh": false,
"settable_per_extruder": true,
"settable_per_meshgroup": false,
"settable_globally": false
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -258,13 +258,13 @@ UM.MainWindow
{
//Insert a separator between readonly and custom profiles
if(separatorIndex < 0 && index > 0) {
if(model.getItem(index-1).metadata.read_only != model.getItem(index).metadata.read_only) {
if(model.getItem(index-1).readOnly != model.getItem(index).readOnly) {
profileMenu.insertSeparator(index);
separatorIndex = index;
}
}
//Because of the separator, custom profiles move one index lower
profileMenu.insertItem((model.getItem(index).metadata.read_only) ? index : index + 1, object.item);
profileMenu.insertItem((model.getItem(index).readOnly) ? index : index + 1, object.item);
}
onObjectRemoved:
{

View File

@ -49,8 +49,7 @@ UM.ManagementPage
onActivateObject: Cura.MachineManager.setActiveQuality(currentItem.id)
onAddObject: {
var selectedContainer;
if (objectList.currentIndex == 0) {
// Current settings
if (objectList.currentItem.id == Cura.MachineManager.activeQualityId) {
selectedContainer = Cura.MachineManager.convertUserContainerToQuality();
} else {
selectedContainer = Cura.MachineManager.duplicateContainer(base.currentItem.id);
@ -66,8 +65,8 @@ UM.ManagementPage
activateEnabled: currentItem != null ? currentItem.id != Cura.MachineManager.activeQualityId : false;
addEnabled: currentItem != null;
removeEnabled: currentItem != null ? !currentItem.metadata.read_only : false;
renameEnabled: currentItem != null ? !currentItem.metadata.read_only : false;
removeEnabled: currentItem != null ? !currentItem.readOnly : false;
renameEnabled: currentItem != null ? !currentItem.readOnly : false;
scrollviewCaption: catalog.i18nc("@label %1 is printer name","Printer: %1").arg(Cura.MachineManager.activeMachineName)

View File

@ -88,13 +88,13 @@ Item{
{
//Insert a separator between readonly and custom profiles
if(separatorIndex < 0 && index > 0) {
if(model.getItem(index-1).metadata.read_only != model.getItem(index).metadata.read_only) {
if(model.getItem(index-1).readOnly != model.getItem(index).readOnly) {
profileSelectionMenu.insertSeparator(index);
separatorIndex = index;
}
}
//Because of the separator, custom profiles move one index lower
profileSelectionMenu.insertItem((model.getItem(index).metadata.read_only) ? index : index + 1, object.item);
profileSelectionMenu.insertItem((model.getItem(index).readOnly) ? index : index + 1, object.item);
}
onObjectRemoved:
{

View File

@ -174,7 +174,7 @@ Item {
break;
}
}
return state && base.showInheritButton && has_setting_function
return state && base.showInheritButton && has_setting_function && typeof(propertyProvider.getPropertyValue("value", base.stackLevels[0])) != "object"
}
height: parent.height;
@ -182,11 +182,9 @@ Item {
onClicked: {
focus = true;
// Get the deepest entry of this setting that we can find. TODO: This is a bit naive, in some cases
// there might be multiple profiles saying something about the same setting. There is no strategy
// how to handle this as of yet.
var last_entry = propertyProvider.stackLevels[propertyProvider.stackLevels.length]
// Get the most shallow function value (eg not a number) that we can find.
var last_entry = propertyProvider.stackLevels[propertyProvider.stackLevels.length]
for (var i = 1; i < base.stackLevels.length; i++)
{
var has_setting_function = typeof(propertyProvider.getPropertyValue("value", base.stackLevels[i])) == "object";
@ -196,18 +194,25 @@ Item {
break;
}
}
// Put that entry into the "top" instance container.
// This ensures that the value in any of the deeper containers need not be removed, which is
// needed for the reset button (which deletes the top value) to correctly go back to profile
// defaults.
if(last_entry == 4 && base.stackLevel == 0 && base.stackLevels.length == 2)
{
// Special case of the inherit reset. If only the definition (4th container) and the first
// entry (user container) are set, we can simply remove the container.
propertyProvider.removeFromContainer(0)
}
else if(last_entry - 1 == base.stackLevel)
{
// Another special case. The setting that is overriden is only 1 instance container deeper,
// so we can remove it.
propertyProvider.removeFromContainer(0)
}
else
{
// Put that entry into the "top" instance container.
// This ensures that the value in any of the deeper containers need not be removed, which is
// needed for the reset button (which deletes the top value) to correctly go back to profile
// defaults.
propertyProvider.setPropertyValue("value", propertyProvider.getPropertyValue("value", last_entry))
propertyProvider.setPropertyValue("state", "InstanceState.Calculated")
}

View File

@ -110,8 +110,9 @@ Item
checked: base.currentExtruderIndex == index
onClicked:
{
base.currentExtruderIndex = index
ExtruderManager.setActiveExtruderIndex(index)
extruderSelection.focus = true; //Changing focus applies the currently-being-typed values so it can change the displayed setting values.
base.currentExtruderIndex = index;
ExtruderManager.setActiveExtruderIndex(index);
}
style: ButtonStyle {

View File

@ -6,7 +6,6 @@ definition = fdmprinter
[metadata]
type = quality
weight = -3
read_only = True
[values]
layer_height = 0.06

View File

@ -6,7 +6,6 @@ definition = fdmprinter
[metadata]
type = quality
weight = -1
read_only = True
[values]
infill_sparse_density = 10

View File

@ -6,6 +6,5 @@ definition = fdmprinter
[metadata]
type = quality
weight = -2
read_only = True
[values]

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_abs_ultimaker2_extended_plus_0.25_mm
weight = -2
read_only = True
[values]
layer_height = 0.06

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_abs_ultimaker2_extended_plus_0.4_mm
weight = -1
read_only = True
[values]
layer_height = 0.15

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_abs_ultimaker2_extended_plus_0.4_mm
weight = -3
read_only = True
[values]
layer_height = 0.06

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_abs_ultimaker2_extended_plus_0.4_mm
weight = -2
read_only = True
[values]
layer_height = 0.1

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_abs_ultimaker2_extended_plus_0.6_mm
weight = -2
read_only = True
[values]
layer_height = 0.15

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_abs_ultimaker2_extended_plus_0.8_mm
weight = -2
read_only = True
[values]
layer_height = 0.2

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_cpe_ultimaker2_extended_plus_0.25_mm
weight = -2
read_only = True
[values]
layer_height = 0.06

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_cpe_ultimaker2_extended_plus_0.4_mm
weight = -1
read_only = True
[values]
layer_height = 0.15

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_cpe_ultimaker2_extended_plus_0.4_mm
weight = -3
read_only = True
[values]
layer_height = 0.06

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_cpe_ultimaker2_extended_plus_0.4_mm
weight = -2
read_only = True
[values]
layer_height = 0.1

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_cpe_ultimaker2_extended_plus_0.6_mm
weight = -2
read_only = True
[values]
layer_height = 0.15

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_cpe_ultimaker2_extended_plus_0.8_mm
weight = -2
read_only = True
[values]
layer_height = 0.2

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_pla_ultimaker2_extended_plus_0.25_mm
weight = -2
read_only = True
[values]
layer_height = 0.06

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_pla_ultimaker2_extended_plus_0.4_mm
weight = -1
read_only = True
[values]
layer_height = 0.15

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_pla_ultimaker2_extended_plus_0.4_mm
weight = -3
read_only = True
[values]
layer_height = 0.06

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
type = quality
material = generic_pla_ultimaker2_extended_plus_0.4_mm
weight = -2
read_only = True
[values]
layer_height = 0.1

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
material = generic_pla_ultimaker2_extended_plus_0.6_mm
type = quality
weight = -2
read_only = True
[values]
layer_height = 0.15

View File

@ -7,7 +7,6 @@ definition = ultimaker2_extended_plus
material = generic_pla_ultimaker2_extended_plus_0.8_mm
type = quality
weight = -2
read_only = True
[values]
layer_height = 0.2

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_pla_ultimaker2_plus_0.25_mm
weight = -2
read_only = True
[values]
layer_height = 0.06

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_pla_ultimaker2_plus_0.4_mm
weight = -1
read_only = True
[values]
layer_height = 0.15

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_pla_ultimaker2_plus_0.4_mm
weight = -3
read_only = True
[values]
layer_height = 0.06

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_pla_ultimaker2_plus_0.4_mm
weight = -2
read_only = True
[values]
layer_height = 0.1

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
material = generic_pla_ultimaker2_plus_0.6_mm
type = quality
weight = -2
read_only = True
[values]
layer_height = 0.15

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
material = generic_pla_ultimaker2_plus_0.8_mm
type = quality
weight = -2
read_only = True
[values]
layer_height = 0.2

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_abs_ultimaker2_plus_0.25_mm
weight = -2
read_only = True
[values]
layer_height = 0.06

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_abs_ultimaker2_plus_0.4_mm
weight = -1
read_only = True
[values]
layer_height = 0.15

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_abs_ultimaker2_plus_0.4_mm
weight = -3
read_only = True
[values]
layer_height = 0.06

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_abs_ultimaker2_plus_0.4_mm
weight = -2
read_only = True
[values]
layer_height = 0.1

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_abs_ultimaker2_plus_0.6_mm
weight = -2
read_only = True
[values]
layer_height = 0.15

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_abs_ultimaker2_plus_0.8_mm
weight = -2
read_only = True
[values]
layer_height = 0.2

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_cpe_ultimaker2_plus_0.25_mm
weight = -2
read_only = True
[values]
layer_height = 0.06

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_cpe_ultimaker2_plus_0.4_mm
weight = -1
read_only = True
[values]
layer_height = 0.15

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_cpe_ultimaker2_plus_0.4_mm
weight = -3
read_only = True
[values]
layer_height = 0.06

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_cpe_ultimaker2_plus_0.4_mm
weight = -2
read_only = True
[values]
layer_height = 0.1

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_cpe_ultimaker2_plus_0.6_mm
weight = -2
read_only = True
[values]
layer_height = 0.15

View File

@ -7,7 +7,6 @@ definition = ultimaker2_plus
type = quality
material = generic_cpe_ultimaker2_plus_0.8_mm
weight = -2
read_only = True
[values]
layer_height = 0.2