mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 00:45:56 +08:00
Merge branch 'infill_mesh_shell_defaults'
This commit is contained in:
commit
089561dd22
@ -1,10 +1,11 @@
|
|||||||
# Copyright (c) 2016 Ultimaker B.V.
|
# Copyright (c) 2020 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtProperty
|
from PyQt5.QtCore import pyqtProperty
|
||||||
from UM.FlameProfiler import pyqtSlot
|
from UM.FlameProfiler import pyqtSlot
|
||||||
|
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
|
from UM.PluginRegistry import PluginRegistry
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
from UM.Settings.SettingInstance import SettingInstance
|
from UM.Settings.SettingInstance import SettingInstance
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
@ -24,6 +25,8 @@ class PerObjectSettingVisibilityHandler(UM.Settings.Models.SettingVisibilityHand
|
|||||||
self._node = None
|
self._node = None
|
||||||
self._stack = None
|
self._stack = None
|
||||||
|
|
||||||
|
PluginRegistry.getInstance().getPluginObject("PerObjectSettingsTool").visibility_handler = self
|
||||||
|
|
||||||
# this is a set of settings that will be skipped if the user chooses to reset.
|
# this is a set of settings that will be skipped if the user chooses to reset.
|
||||||
self._skip_reset_setting_set = set()
|
self._skip_reset_setting_set = set()
|
||||||
|
|
||||||
@ -68,7 +71,7 @@ class PerObjectSettingVisibilityHandler(UM.Settings.Models.SettingVisibilityHand
|
|||||||
|
|
||||||
# Add all instances that are not added, but are in visibility list
|
# Add all instances that are not added, but are in visibility list
|
||||||
for item in visible:
|
for item in visible:
|
||||||
if not settings.getInstance(item): # Setting was not added already.
|
if settings.getInstance(item) is not None: # Setting was not added already.
|
||||||
definition = self._stack.getSettingDefinition(item)
|
definition = self._stack.getSettingDefinition(item)
|
||||||
if definition:
|
if definition:
|
||||||
new_instance = SettingInstance(definition, settings)
|
new_instance = SettingInstance(definition, settings)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# Copyright (c) 2016 Ultimaker B.V.
|
# Copyright (c) 2020 Ultimaker B.V.
|
||||||
# Uranium is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Tool import Tool
|
from UM.Tool import Tool
|
||||||
from UM.Scene.Selection import Selection
|
from UM.Scene.Selection import Selection
|
||||||
@ -22,14 +23,13 @@ class PerObjectSettingsTool(Tool):
|
|||||||
|
|
||||||
self._multi_extrusion = False
|
self._multi_extrusion = False
|
||||||
self._single_model_selected = False
|
self._single_model_selected = False
|
||||||
|
self.visibility_handler = None
|
||||||
|
|
||||||
Selection.selectionChanged.connect(self.propertyChanged)
|
Selection.selectionChanged.connect(self.propertyChanged)
|
||||||
|
|
||||||
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged)
|
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged)
|
||||||
self._onGlobalContainerChanged()
|
self._onGlobalContainerChanged()
|
||||||
Selection.selectionChanged.connect(self._updateEnabled)
|
Selection.selectionChanged.connect(self._updateEnabled)
|
||||||
|
|
||||||
|
|
||||||
def event(self, event):
|
def event(self, event):
|
||||||
super().event(event)
|
super().event(event)
|
||||||
if event.type == Event.MousePressEvent and self._controller.getToolsEnabled():
|
if event.type == Event.MousePressEvent and self._controller.getToolsEnabled():
|
||||||
@ -68,7 +68,8 @@ class PerObjectSettingsTool(Tool):
|
|||||||
|
|
||||||
## Returns True when the mesh_type was changed, False when current mesh_type == mesh_type
|
## Returns True when the mesh_type was changed, False when current mesh_type == mesh_type
|
||||||
def setMeshType(self, mesh_type: str) -> bool:
|
def setMeshType(self, mesh_type: str) -> bool:
|
||||||
if self.getMeshType() == mesh_type:
|
old_mesh_type = self.getMeshType()
|
||||||
|
if old_mesh_type == mesh_type:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
selected_object = Selection.getSelectedObject(0)
|
selected_object = Selection.getSelectedObject(0)
|
||||||
@ -94,6 +95,20 @@ 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)
|
||||||
|
|
||||||
|
for property_key in ["top_bottom_thickness", "wall_thickness"]:
|
||||||
|
if mesh_type == "infill_mesh":
|
||||||
|
if not settings.getInstance(property_key):
|
||||||
|
definition = stack.getSettingDefinition(property_key)
|
||||||
|
new_instance = SettingInstance(definition, settings)
|
||||||
|
new_instance.setProperty("value", 0)
|
||||||
|
new_instance.resetState() # Ensure that the state is not seen as a user state.
|
||||||
|
settings.addInstance(new_instance)
|
||||||
|
visible = self.visibility_handler.getVisible()
|
||||||
|
visible.add(property_key)
|
||||||
|
self.visibility_handler.setVisible(visible)
|
||||||
|
elif old_mesh_type == "infill_mesh" and settings.getInstance(property_key) and settings.getProperty(property_key, "value") == 0:
|
||||||
|
settings.removeInstance(property_key)
|
||||||
|
|
||||||
self.propertyChanged.emit()
|
self.propertyChanged.emit()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user