mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Show support settings when support meshes are present in the scene
This commit is contained in:
parent
485e37e7f5
commit
6e09e9821f
3 changed files with 129 additions and 83 deletions
|
@ -6,13 +6,15 @@ from PyQt5.QtWidgets import QApplication
|
|||
from UM.Scene.Camera import Camera
|
||||
from cura.UI.ObjectsModel import ObjectsModel
|
||||
from cura.Machines.Models.MultiBuildPlateModel import MultiBuildPlateModel
|
||||
from cura.Scene.CuraSceneNode import CuraSceneNode
|
||||
|
||||
from UM.Application import Application
|
||||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
||||
from UM.Scene.SceneNode import SceneNode
|
||||
from UM.Scene.Selection import Selection
|
||||
from UM.Signal import Signal
|
||||
|
||||
from UM.Settings.SettingFunction import SettingFunction
|
||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||
|
||||
class CuraSceneController(QObject):
|
||||
activeBuildPlateChanged = Signal()
|
||||
|
@ -43,6 +45,24 @@ class CuraSceneController(QObject):
|
|||
self._change_timer.start()
|
||||
|
||||
def updateMaxBuildPlate(self, *args):
|
||||
global_stack = Application.getInstance().getGlobalContainerStack()
|
||||
if global_stack:
|
||||
scene_has_support_meshes = self._sceneHasSupportMeshes() # TODO: see if this can be cached
|
||||
if scene_has_support_meshes != global_stack.getProperty("support_meshes_present", "value"):
|
||||
# adjust the setting without having the setting value in an InstanceContainer
|
||||
setting_definitions = global_stack.definition.findDefinitions(key="support_meshes_present")
|
||||
if setting_definitions:
|
||||
relations = setting_definitions[0].relations
|
||||
definition_dict = setting_definitions[0].serialize_to_dict()
|
||||
definition_dict["enabled"] = False
|
||||
definition_dict["default_value"] = scene_has_support_meshes
|
||||
setting_definitions[0].deserialize(definition_dict)
|
||||
setting_definitions[0]._relations = relations # TODO: find a better way to restore relations
|
||||
|
||||
# notify relations that the setting has changed
|
||||
for relation in relations:
|
||||
global_stack.propertyChanged.emit(relation.target.key, "enabled")
|
||||
|
||||
max_build_plate = self._calcMaxBuildPlate()
|
||||
changed = False
|
||||
if max_build_plate != self._max_build_plate:
|
||||
|
@ -72,6 +92,15 @@ class CuraSceneController(QObject):
|
|||
max_build_plate = max(build_plate_number, max_build_plate)
|
||||
return max_build_plate
|
||||
|
||||
def _sceneHasSupportMeshes(self):
|
||||
root = Application.getInstance().getController().getScene().getRoot()
|
||||
for node in root.getAllChildren():
|
||||
if isinstance(node, CuraSceneNode):
|
||||
per_mesh_stack = node.callDecoration("getStack")
|
||||
if per_mesh_stack and per_mesh_stack.getProperty("support_mesh", "value"):
|
||||
return True
|
||||
return False
|
||||
|
||||
## Either select or deselect an item
|
||||
@pyqtSlot(int)
|
||||
def changeSelection(self, index):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue