Bind current_mesh_type to UM.ActiveTool.properties.getValue("MeshType")

CURA-6683
This commit is contained in:
Nino van Hooff 2019-09-13 10:55:05 +02:00
parent 5db122aff6
commit 184a72f7ab
2 changed files with 15 additions and 14 deletions

View file

@ -24,11 +24,11 @@ Item
readonly property string infill_mesh_type: "infill_mesh" readonly property string infill_mesh_type: "infill_mesh"
readonly property string anti_overhang_mesh_type: "anti_overhang_mesh" readonly property string anti_overhang_mesh_type: "anti_overhang_mesh"
property var current_mesh_type: normal_mesh_type property var current_mesh_type: UM.ActiveTool.properties.getValue("MeshType")
function setOverhangsMeshType(){ function setOverhangsMeshType(){
if(infillOnlyCheckbox.checked) if (infillOnlyCheckbox.checked)
{ {
setMeshType(infill_mesh_type) setMeshType(infill_mesh_type)
} }
@ -39,19 +39,13 @@ Item
} }
function setMeshType(type) { function setMeshType(type) {
current_mesh_type = type
// update the active object
if(UM.ActiveTool.properties.getValue("MeshType") !== type)
{
UM.ActiveTool.setProperty("MeshType", type) UM.ActiveTool.setProperty("MeshType", type)
}
// set checked state of mesh type buttons // set checked state of mesh type buttons
normalButton.checked = current_mesh_type === normal_mesh_type normalButton.checked = type === normal_mesh_type
supportMeshButton.checked = current_mesh_type === support_mesh_type supportMeshButton.checked = type === support_mesh_type
overhangMeshButton.checked = current_mesh_type === infill_mesh_type || current_mesh_type === cutting_mesh_type overhangMeshButton.checked = type === infill_mesh_type || type === cutting_mesh_type
antiOverhangMeshButton.checked = current_mesh_type === anti_overhang_mesh_type antiOverhangMeshButton.checked = type === anti_overhang_mesh_type
// update active type label // update active type label
for (var button in meshTypeButtons.children) for (var button in meshTypeButtons.children)

View file

@ -66,7 +66,11 @@ class PerObjectSettingsTool(Tool):
selected_object.addDecorator(SettingOverrideDecorator()) selected_object.addDecorator(SettingOverrideDecorator())
selected_object.callDecoration("setActiveExtruder", extruder_stack_id) selected_object.callDecoration("setActiveExtruder", extruder_stack_id)
def setMeshType(self, mesh_type): ## Returns True when the mesh_type was changed, False when current mesh_type == mesh_type
def setMeshType(self, mesh_type) -> bool:
if self.getMeshType() == mesh_type:
return False
selected_object = Selection.getSelectedObject(0) selected_object = Selection.getSelectedObject(0)
stack = selected_object.callDecoration("getStack") #Don't try to get the active extruder since it may be None anyway. stack = selected_object.callDecoration("getStack") #Don't try to get the active extruder since it may be None anyway.
if not stack: if not stack:
@ -86,6 +90,9 @@ class PerObjectSettingsTool(Tool):
new_instance.resetState() # Ensure that the state is not seen as a user state. new_instance.resetState() # Ensure that the state is not seen as a user state.
settings.addInstance(new_instance) settings.addInstance(new_instance)
self.propertyChanged.emit()
return True
def getMeshType(self): def getMeshType(self):
selected_object = Selection.getSelectedObject(0) selected_object = Selection.getSelectedObject(0)
stack = selected_object.callDecoration("getStack") #Don't try to get the active extruder since it may be None anyway. stack = selected_object.callDecoration("getStack") #Don't try to get the active extruder since it may be None anyway.