mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-21 13:19:37 +08:00

Contributes to CURA-1278 * settings_rework: (224 commits) Improve slice trigger documentation Import Cura in materials preferences page so we can use the active definition id Add layer height to high quality profile so we have something that changes Update example XML material to use the right product names Filter available materials by the machine definition Show the add machine dialog when we do not have an active machine Create machine-specific material containers for machine specific overrides in XML material files When creating a new container stack, add empty containers for things where we cannot find containers Add preferred variant, material and quality to UM2+ definition Account for global container stack being None in the backend plugin Use the global stack instance variable and account for it potentially being None Store the global container stack as an instance property Added wildcard to filtering Per object settings filter now uses correct bool types (instead of strings) Removed stray = sign. Fix creating print job name Disable asynchronous loading of SettingItem when Qt Version < 5.5 Document QTbug Properly serialise all settings to g-code file Document GCodeWriter class ...
123 lines
4.6 KiB
Python
123 lines
4.6 KiB
Python
from UM.Scene.SceneNodeDecorator import SceneNodeDecorator
|
|
from UM.Application import Application
|
|
|
|
|
|
## The convex hull decorator is a scene node decorator that adds the convex hull functionality to a scene node.
|
|
# If a scene node has a convex hull decorator, it will have a shadow in which other objects can not be printed.
|
|
class ConvexHullDecorator(SceneNodeDecorator):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self._convex_hull = None
|
|
|
|
# In case of printing all at once this is the same as the convex hull.
|
|
# For one at the time this is the area without the head.
|
|
self._convex_hull_boundary = None
|
|
|
|
# In case of printing all at once this is the same as the convex hull.
|
|
# For one at the time this is area with intersection of mirrored head
|
|
self._convex_hull_head = None
|
|
|
|
# In case of printing all at once this is the same as the convex hull.
|
|
# For one at the time this is area with intersection of full head
|
|
self._convex_hull_head_full = None
|
|
|
|
self._convex_hull_node = None
|
|
self._convex_hull_job = None
|
|
|
|
# Keep track of the previous parent so we can clear its convex hull when the object is reparented
|
|
self._parent_node = None
|
|
|
|
self._profile = None
|
|
#Application.getInstance().getMachineManager().activeProfileChanged.connect(self._onActiveProfileChanged)
|
|
#Application.getInstance().getMachineManager().activeMachineInstanceChanged.connect(self._onActiveMachineInstanceChanged)
|
|
#self._onActiveProfileChanged()
|
|
|
|
def setNode(self, node):
|
|
super().setNode(node)
|
|
self._parent_node = node.getParent()
|
|
node.parentChanged.connect(self._onParentChanged)
|
|
|
|
## Force that a new (empty) object is created upon copy.
|
|
def __deepcopy__(self, memo):
|
|
copy = ConvexHullDecorator()
|
|
return copy
|
|
|
|
## Get the unmodified convex hull of the node
|
|
def getConvexHull(self):
|
|
return self._convex_hull
|
|
|
|
## Get the convex hull of the node with the full head size
|
|
def getConvexHullHeadFull(self):
|
|
if not self._convex_hull_head_full:
|
|
return self.getConvexHull()
|
|
return self._convex_hull_head_full
|
|
|
|
## Get convex hull of the object + head size
|
|
# In case of printing all at once this is the same as the convex hull.
|
|
# For one at the time this is area with intersection of mirrored head
|
|
def getConvexHullHead(self):
|
|
if not self._convex_hull_head:
|
|
return self.getConvexHull()
|
|
return self._convex_hull_head
|
|
|
|
## Get convex hull of the node
|
|
# In case of printing all at once this is the same as the convex hull.
|
|
# For one at the time this is the area without the head.
|
|
def getConvexHullBoundary(self):
|
|
if not self._convex_hull_boundary:
|
|
return self.getConvexHull()
|
|
return self._convex_hull_boundary
|
|
|
|
def setConvexHullBoundary(self, hull):
|
|
self._convex_hull_boundary = hull
|
|
|
|
def setConvexHullHeadFull(self, hull):
|
|
self._convex_hull_head_full = hull
|
|
|
|
def setConvexHullHead(self, hull):
|
|
self._convex_hull_head = hull
|
|
|
|
def setConvexHull(self, hull):
|
|
self._convex_hull = hull
|
|
if not hull and self._convex_hull_node:
|
|
self._convex_hull_node.setParent(None)
|
|
self._convex_hull_node = None
|
|
|
|
def getConvexHullJob(self):
|
|
return self._convex_hull_job
|
|
|
|
def setConvexHullJob(self, job):
|
|
self._convex_hull_job = job
|
|
|
|
def getConvexHullNode(self):
|
|
return self._convex_hull_node
|
|
|
|
def setConvexHullNode(self, node):
|
|
self._convex_hull_node = node
|
|
|
|
def _onActiveProfileChanged(self):
|
|
if self._profile:
|
|
self._profile.settingValueChanged.disconnect(self._onSettingValueChanged)
|
|
|
|
self._profile = Application.getInstance().getMachineManager().getWorkingProfile()
|
|
|
|
if self._profile:
|
|
self._profile.settingValueChanged.connect(self._onSettingValueChanged)
|
|
|
|
def _onActiveMachineInstanceChanged(self):
|
|
if self._convex_hull_job:
|
|
self._convex_hull_job.cancel()
|
|
self.setConvexHull(None)
|
|
|
|
def _onSettingValueChanged(self, setting):
|
|
if setting == "print_sequence":
|
|
if self._convex_hull_job:
|
|
self._convex_hull_job.cancel()
|
|
self.setConvexHull(None)
|
|
|
|
def _onParentChanged(self, node):
|
|
# Force updating the convex hull of the parent group if the object is in a group
|
|
if self._parent_node and self._parent_node.callDecoration("isGroup"):
|
|
self._parent_node.callDecoration("setConvexHull", None)
|
|
self._parent_node = self.getNode().getParent()
|