Update mesh type dropdown when to reflect the selected object

This commit is contained in:
fieldOfView 2017-11-09 21:42:10 +01:00
parent 9c3e50c494
commit a1320939e8
2 changed files with 37 additions and 1 deletions

View file

@ -67,9 +67,32 @@ Item {
type: "cutting_mesh", type: "cutting_mesh",
text: catalog.i18nc("@label", "Modify extruder or settings for overlap with other models") text: catalog.i18nc("@label", "Modify extruder or settings for overlap with other models")
}); });
meshTypeSelection.updateCurrentIndex();
} }
} }
function updateCurrentIndex()
{
var mesh_type = UM.ActiveTool.properties.getValue("MeshType");
for(var index=0; index < meshTypeSelection.model.count; index++)
{
if(meshTypeSelection.model.get(index).type == mesh_type)
{
meshTypeSelection.currentIndex = index;
return;
}
}
meshTypeSelection.currentIndex = 0;
}
} }
Connections
{
target: UM.Selection
onSelectionChanged: meshTypeSelection.updateCurrentIndex()
}
} }
Column Column

View file

@ -19,7 +19,7 @@ class PerObjectSettingsTool(Tool):
super().__init__() super().__init__()
self._model = None self._model = None
self.setExposedProperties("SelectedObjectId", "ContainerID", "SelectedActiveExtruder") self.setExposedProperties("SelectedObjectId", "ContainerID", "SelectedActiveExtruder", "MeshType")
self._advanced_mode = False self._advanced_mode = False
self._multi_extrusion = False self._multi_extrusion = False
@ -91,6 +91,19 @@ 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)
def getMeshType(self):
selected_object = Selection.getSelectedObject(0)
stack = selected_object.callDecoration("getStack") #Don't try to get the active extruder since it may be None anyway.
if not stack:
return ""
settings = stack.getTop()
for property_key in ["infill_mesh", "cutting_mesh", "support_mesh", "anti_overhang_mesh"]:
if settings.getInstance(property_key) and settings.getProperty(property_key, "value"):
return property_key
return ""
def _onPreferenceChanged(self, preference): def _onPreferenceChanged(self, preference):
if preference == "cura/active_mode": if preference == "cura/active_mode":
self._advanced_mode = Preferences.getInstance().getValue(preference) == 1 self._advanced_mode = Preferences.getInstance().getValue(preference) == 1