Merge branch 'feature_intent' of github.com:Ultimaker/Cura into feature_intent

This commit is contained in:
Jaime van Kessel 2019-10-08 10:37:40 +02:00
commit e6d19d9244
No known key found for this signature in database
GPG Key ID: 3710727397403C91
10 changed files with 90 additions and 82 deletions

View File

@ -1620,8 +1620,12 @@ class CuraApplication(QtApplication):
openProjectFile = pyqtSignal(QUrl, arguments = ["project_file"]) # Emitted when a project file is about to open. openProjectFile = pyqtSignal(QUrl, arguments = ["project_file"]) # Emitted when a project file is about to open.
@pyqtSlot(QUrl, bool) @pyqtSlot(QUrl, str)
def readLocalFile(self, file, skip_project_file_check = False): @pyqtSlot(QUrl)
## Open a local file
# \param project_mode How to handle project files. Either None(default): Follow user preference, "open_as_model" or
# "open_as_project". This parameter is only considered if the file is a project file.
def readLocalFile(self, file: QUrl, project_mode: Optional[str] = None):
if not file.isValid(): if not file.isValid():
return return
@ -1632,10 +1636,24 @@ class CuraApplication(QtApplication):
self.deleteAll() self.deleteAll()
break break
if not skip_project_file_check and self.checkIsValidProjectFile(file): is_project_file = self.checkIsValidProjectFile(file)
if project_mode is None:
project_mode = self.getPreferences().getValue("cura/choice_on_open_project")
if is_project_file and project_mode == "open_as_project":
# open as project immediately without presenting a dialog
workspace_handler = self.getWorkspaceFileHandler()
workspace_handler.readLocalFile(file)
return
if is_project_file and project_mode == "always_ask":
# present a dialog asking to open as project or import models
self.callLater(self.openProjectFile.emit, file) self.callLater(self.openProjectFile.emit, file)
return return
# Either the file is a model file or we want to load only models from project. Continue to load models.
if self.getPreferences().getValue("cura/select_models_on_load"): if self.getPreferences().getValue("cura/select_models_on_load"):
Selection.clear() Selection.clear()

View File

@ -1592,18 +1592,20 @@ class MachineManager(QObject):
if not no_dialog and self.hasUserSettings and self._application.getPreferences().getValue("cura/active_mode") == 1: if not no_dialog and self.hasUserSettings and self._application.getPreferences().getValue("cura/active_mode") == 1:
self._application.discardOrKeepProfileChanges() self._application.discardOrKeepProfileChanges()
# The display name of currently active quality. # The display name map of currently active quality.
# The display name has 2 parts, a main part and a suffix part.
# This display name is: # This display name is:
# - For built-in qualities (quality/intent): the quality type name, such as "Fine", "Normal", etc. # - For built-in qualities (quality/intent): the quality type name, such as "Fine", "Normal", etc.
# - For custom qualities: <custom_quality_name> - <intent_name> - <quality_type_name> # - For custom qualities: <custom_quality_name> - <intent_name> - <quality_type_name>
# Examples: # Examples:
# - "my_profile - Fine" (only based on a default quality, no intent involved) # - "my_profile - Fine" (only based on a default quality, no intent involved)
# - "my_profile - Engineering - Fine" (based on an intent) # - "my_profile - Engineering - Fine" (based on an intent)
@pyqtProperty(str, notify = activeQualityDisplayNameChanged) @pyqtProperty("QVariantMap", notify = activeQualityDisplayNameChanged)
def activeQualityDisplayName(self) -> str: def activeQualityDisplayNameMap(self) -> Dict[str, str]:
global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack() global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
if global_stack is None: if global_stack is None:
return "" return {"main": "",
"suffix": ""}
display_name = global_stack.quality.getName() display_name = global_stack.quality.getName()
@ -1614,11 +1616,16 @@ class MachineManager(QObject):
display_name = "{intent_name} - {the_rest}".format(intent_name = intent_display_name, display_name = "{intent_name} - {the_rest}".format(intent_name = intent_display_name,
the_rest = display_name) the_rest = display_name)
main_part = display_name
suffix_part = ""
# Not a custom quality # Not a custom quality
if global_stack.qualityChanges != empty_quality_changes_container: if global_stack.qualityChanges != empty_quality_changes_container:
display_name = self.activeQualityOrQualityChangesName + " - " + display_name main_part = self.activeQualityOrQualityChangesName
suffix_part = display_name
return display_name return {"main": main_part,
"suffix": suffix_part}
## Change the intent category of the current printer. ## Change the intent category of the current printer.
# #

View File

@ -87,7 +87,7 @@ class SingleInstance:
if command == "clear-all": if command == "clear-all":
self._application.callLater(lambda: self._application.deleteAll()) self._application.callLater(lambda: self._application.deleteAll())
# Command: Load a model file # Command: Load a model or project file
elif command == "open": elif command == "open":
self._application.callLater(lambda f = payload["filePath"]: self._application._openFile(f)) self._application.callLater(lambda f = payload["filePath"]: self._application._openFile(f))

View File

@ -5832,6 +5832,32 @@
"enabled": "not (support_enable or support_tree_enable)", "enabled": "not (support_enable or support_tree_enable)",
"settable_per_mesh": false, "settable_per_mesh": false,
"settable_per_extruder": false "settable_per_extruder": false
},
"meshfix_maximum_travel_resolution":
{
"label": "Maximum Travel Resolution",
"description": "The minimum size of a travel line segment after slicing. If you increase this, the travel moves will have less smooth corners. This may allow the printer to keep up with the speed it has to process g-code, but it may cause model avoidance to become less accurate.",
"type": "float",
"unit": "mm",
"default_value": 1.0,
"value": "min(meshfix_maximum_resolution * speed_travel / speed_print, 2 * line_width)",
"minimum_value": "0.001",
"minimum_value_warning": "0.05",
"maximum_value_warning": "10",
"settable_per_mesh": false,
"settable_per_extruder": true
},
"meshfix_maximum_deviation":
{
"label": "Maximum Deviation",
"description": "The maximum deviation allowed when reducing the resolution for the Maximum Resolution setting. If you increase this, the print will be less accurate, but the g-code will be smaller. Maximum Deviation is a limit for Maximum Resolution, so if the two conflict the Maximum Deviation will always be held true.",
"type": "float",
"unit": "mm",
"default_value": 0.05,
"minimum_value": "0.001",
"minimum_value_warning": "0.01",
"maximum_value_warning": "0.3",
"settable_per_mesh": true
} }
} }
}, },
@ -6222,7 +6248,7 @@
"unit": "mm", "unit": "mm",
"type": "float", "type": "float",
"default_value": 1.0, "default_value": 1.0,
"minimum_value": "0.001", "minimum_value": "0",
"minimum_value_warning": "0.05", "minimum_value_warning": "0.05",
"maximum_value_warning": "1.0", "maximum_value_warning": "1.0",
"settable_per_mesh": true, "settable_per_mesh": true,
@ -6240,32 +6266,6 @@
"maximum_value_warning": "3", "maximum_value_warning": "3",
"settable_per_mesh": true "settable_per_mesh": true
}, },
"meshfix_maximum_travel_resolution":
{
"label": "Maximum Travel Resolution",
"description": "The minimum size of a travel line segment after slicing. If you increase this, the travel moves will have less smooth corners. This may allow the printer to keep up with the speed it has to process g-code, but it may cause model avoidance to become less accurate.",
"type": "float",
"unit": "mm",
"default_value": 1.0,
"value": "min(meshfix_maximum_resolution * speed_travel / speed_print, 2 * line_width)",
"minimum_value": "0.001",
"minimum_value_warning": "0.05",
"maximum_value_warning": "10",
"settable_per_mesh": false,
"settable_per_extruder": true
},
"meshfix_maximum_deviation":
{
"label": "Maximum Deviation",
"description": "The maximum deviation allowed when reducing the resolution for the Maximum Resolution setting. If you increase this, the print will be less accurate, but the g-code will be smaller. Maximum Deviation is a limit for Maximum Resolution, so if the two conflict the Maximum Deviation will always be held true.",
"type": "float",
"unit": "mm",
"default_value": 0.05,
"minimum_value": "0.001",
"minimum_value_warning": "0.01",
"maximum_value_warning": "0.3",
"settable_per_mesh": true
},
"support_skip_some_zags": "support_skip_some_zags":
{ {
"label": "Break Up Support In Chunks", "label": "Break Up Support In Chunks",

View File

@ -53,7 +53,7 @@ UM.Dialog
UM.Preferences.setValue("cura/choice_on_open_project", "open_as_model") UM.Preferences.setValue("cura/choice_on_open_project", "open_as_model")
} }
CuraApplication.readLocalFile(base.fileUrl, true) CuraApplication.readLocalFile(base.fileUrl, "open_as_model")
var meshName = backgroundItem.getMeshName(base.fileUrl.toString()) var meshName = backgroundItem.getMeshName(base.fileUrl.toString())
backgroundItem.hasMesh(decodeURIComponent(meshName)) backgroundItem.hasMesh(decodeURIComponent(meshName))

View File

@ -42,7 +42,7 @@ UM.Dialog
{ {
for (var i in fileUrls) for (var i in fileUrls)
{ {
CuraApplication.readLocalFile(fileUrls[i], true); CuraApplication.readLocalFile(fileUrls[i], "open_as_model");
} }
var meshName = backgroundItem.getMeshName(fileUrls[0].toString()); var meshName = backgroundItem.getMeshName(fileUrls[0].toString());

View File

@ -24,7 +24,7 @@ import Cura 1.1 as Cura
// //
NumericTextFieldWithUnit NumericTextFieldWithUnit
{ {
id: machineXMaxField id: printerHeadMinMaxField
UM.I18nCatalog { id: catalog; name: "cura" } UM.I18nCatalog { id: catalog; name: "cura" }
containerStackId: Cura.MachineManager.activeMachineId containerStackId: Cura.MachineManager.activeMachineId
@ -64,7 +64,7 @@ NumericTextFieldWithUnit
// show the correct value. // show the correct value.
if (!textField.activeFocus && !textField.acceptableInput) if (!textField.activeFocus && !textField.acceptableInput)
{ {
valueText = axisValue valueText = Qt.binding(function() { return printerHeadMinMaxField.axisValue })
} }
} }
} }
@ -94,6 +94,6 @@ NumericTextFieldWithUnit
} }
// Recreate the binding to show the correct value. // Recreate the binding to show the correct value.
valueText = axisValue valueText = Qt.binding(function() { return axisValue })
} }
} }

View File

@ -29,42 +29,8 @@ Menu
} }
onTriggered: onTriggered:
{ {
var toShowDialog = false; CuraApplication.readLocalFile(modelData);
var toOpenAsProject = false;
var toOpenAsModel = false;
if (CuraApplication.checkIsValidProjectFile(modelData)) {
// check preference
var choice = UM.Preferences.getValue("cura/choice_on_open_project");
if (choice == "open_as_project")
{
toOpenAsProject = true;
}else if (choice == "open_as_model"){
toOpenAsModel = true;
}else{
toShowDialog = true;
}
}
else {
toOpenAsModel = true;
}
if (toShowDialog) {
askOpenAsProjectOrModelsDialog.fileUrl = modelData;
askOpenAsProjectOrModelsDialog.show();
return;
}
// open file in the prefered way
if (toOpenAsProject)
{
UM.WorkspaceFileHandler.readLocalFile(modelData);
}
else if (toOpenAsModel)
{
CuraApplication.readLocalFile(modelData, true);
}
var meshName = backgroundItem.getMeshName(modelData.toString()) var meshName = backgroundItem.getMeshName(modelData.toString())
backgroundItem.hasMesh(decodeURIComponent(meshName)) backgroundItem.hasMesh(decodeURIComponent(meshName))
} }

View File

@ -100,18 +100,30 @@ Item
function generateActiveQualityText() function generateActiveQualityText()
{ {
var result = Cura.MachineManager.activeQualityDisplayName var resultMap = Cura.MachineManager.activeQualityDisplayNameMap
var resultMain = resultMap["main"]
var resultSuffix = resultMap["suffix"]
var result = ""
if (Cura.MachineManager.isActiveQualityExperimental) if (Cura.MachineManager.isActiveQualityExperimental)
{ {
result += " (Experimental)" resultSuffix += " (Experimental)"
} }
if (Cura.MachineManager.isActiveQualitySupported) if (Cura.MachineManager.isActiveQualitySupported)
{ {
if (Cura.MachineManager.activeQualityLayerHeight > 0) if (Cura.MachineManager.activeQualityLayerHeight > 0)
{ {
result = resultMain
if (resultSuffix)
{
result += " - "
}
result += "<font color=\"" + UM.Theme.getColor("text_detail") + "\">" result += "<font color=\"" + UM.Theme.getColor("text_detail") + "\">"
if (resultSuffix)
{
result += resultSuffix
}
result += " - " result += " - "
result += Cura.MachineManager.activeQualityLayerHeight + "mm" result += Cura.MachineManager.activeQualityLayerHeight + "mm"
result += "</font>" result += "</font>"

View File

@ -20,7 +20,12 @@ RowLayout
{ {
if (Cura.MachineManager.activeStack) if (Cura.MachineManager.activeStack)
{ {
var text = Cura.MachineManager.activeQualityDisplayName var resultMap = Cura.MachineManager.activeQualityDisplayNameMap
var text = resultMap["main"]
if (resultMap["suffix"])
{
text += " - " + resultMap["suffix"]
}
if (!Cura.MachineManager.hasNotSupportedQuality) if (!Cura.MachineManager.hasNotSupportedQuality)
{ {