mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 23:23:57 -06:00
BuildVolume now uses StackContainer
CURA-1278
This commit is contained in:
parent
6dc7476839
commit
c0c24f1f70
1 changed files with 32 additions and 46 deletions
|
@ -39,11 +39,8 @@ class BuildVolume(SceneNode):
|
||||||
|
|
||||||
self._active_profile = None
|
self._active_profile = None
|
||||||
self._active_instance = None
|
self._active_instance = None
|
||||||
Application.getInstance().getMachineManager().activeMachineInstanceChanged.connect(self._onActiveInstanceChanged)
|
Application.getInstance().activeContainerStackChanged.connect(self._onActiveContainerStackChanged)
|
||||||
self._onActiveInstanceChanged()
|
self._onActiveContainerStackChanged()
|
||||||
|
|
||||||
Application.getInstance().getMachineManager().activeProfileChanged.connect(self._onActiveProfileChanged)
|
|
||||||
self._onActiveProfileChanged()
|
|
||||||
|
|
||||||
def setWidth(self, width):
|
def setWidth(self, width):
|
||||||
if width: self._width = width
|
if width: self._width = width
|
||||||
|
@ -148,9 +145,9 @@ class BuildVolume(SceneNode):
|
||||||
|
|
||||||
skirt_size = 0.0
|
skirt_size = 0.0
|
||||||
|
|
||||||
profile = Application.getInstance().getMachineManager().getWorkingProfile()
|
container_stack = Application.getInstance().getActiveContainerStack()
|
||||||
if profile:
|
if container_stack:
|
||||||
skirt_size = self._getSkirtSize(profile)
|
skirt_size = self._getSkirtSize(container_stack)
|
||||||
|
|
||||||
# As this works better for UM machines, we only add the disallowed_area_size for the z direction.
|
# As this works better for UM machines, we only add the disallowed_area_size for the z direction.
|
||||||
# This is probably wrong in all other cases. TODO!
|
# This is probably wrong in all other cases. TODO!
|
||||||
|
@ -162,52 +159,41 @@ class BuildVolume(SceneNode):
|
||||||
|
|
||||||
Application.getInstance().getController().getScene()._maximum_bounds = scale_to_max_bounds
|
Application.getInstance().getController().getScene()._maximum_bounds = scale_to_max_bounds
|
||||||
|
|
||||||
def _onActiveInstanceChanged(self):
|
def _onActiveContainerStackChanged(self):
|
||||||
self._active_instance = Application.getInstance().getMachineManager().getActiveMachineInstance()
|
self._active_container_stack = Application.getInstance().getActiveContainerStack()
|
||||||
|
|
||||||
if self._active_instance:
|
if self._active_container_stack:
|
||||||
self._width = self._active_instance.getMachineSettingValue("machine_width")
|
self._width = self._active_container_stack.getValue("machine_width")
|
||||||
if Application.getInstance().getMachineManager().getWorkingProfile().getSettingValue("print_sequence") == "one_at_a_time":
|
if self._active_container_stack.getValue("print_sequence") == "one_at_a_time":
|
||||||
self._height = Application.getInstance().getMachineManager().getWorkingProfile().getSettingValue("gantry_height")
|
self._height = self._active_container_stack.getValue("gantry_height")
|
||||||
else:
|
else:
|
||||||
self._height = self._active_instance.getMachineSettingValue("machine_height")
|
self._height = self._active_container_stack.getValue("machine_height")
|
||||||
self._depth = self._active_instance.getMachineSettingValue("machine_depth")
|
self._depth = self._active_container_stack.getValue("machine_depth")
|
||||||
|
|
||||||
self._updateDisallowedAreas()
|
self._updateDisallowedAreas()
|
||||||
|
|
||||||
self.rebuild()
|
self.rebuild()
|
||||||
|
|
||||||
def _onActiveProfileChanged(self):
|
|
||||||
if self._active_profile:
|
|
||||||
self._active_profile.settingValueChanged.disconnect(self._onSettingValueChanged)
|
|
||||||
|
|
||||||
self._active_profile = Application.getInstance().getMachineManager().getWorkingProfile()
|
|
||||||
if self._active_profile:
|
|
||||||
self._active_profile.settingValueChanged.connect(self._onSettingValueChanged)
|
|
||||||
self._updateDisallowedAreas()
|
|
||||||
self.rebuild()
|
|
||||||
|
|
||||||
def _onSettingValueChanged(self, setting_key):
|
def _onSettingValueChanged(self, setting_key):
|
||||||
if setting_key == "print_sequence":
|
if setting_key == "print_sequence":
|
||||||
if Application.getInstance().getMachineManager().getWorkingProfile().getSettingValue("print_sequence") == "one_at_a_time":
|
if Application.getInstance().getActiveContainerStack().getValue("print_sequence") == "one_at_a_time":
|
||||||
self._height = Application.getInstance().getMachineManager().getWorkingProfile().getSettingValue("gantry_height")
|
self._height = self._active_container_stack.getValue("gantry_height")
|
||||||
else:
|
else:
|
||||||
self._height = self._active_instance.getMachineSettingValue("machine_depth")
|
self._height = self._active_container_stack.getValue("machine_depth")
|
||||||
self.rebuild()
|
self.rebuild()
|
||||||
if setting_key in self._skirt_settings:
|
if setting_key in self._skirt_settings:
|
||||||
self._updateDisallowedAreas()
|
self._updateDisallowedAreas()
|
||||||
self.rebuild()
|
self.rebuild()
|
||||||
|
|
||||||
def _updateDisallowedAreas(self):
|
def _updateDisallowedAreas(self):
|
||||||
if not self._active_instance or not self._active_profile:
|
if not self._active_container_stack:
|
||||||
return
|
return
|
||||||
|
|
||||||
disallowed_areas = self._active_instance.getMachineSettingValue("machine_disallowed_areas")
|
disallowed_areas = self._active_container_stack.getValue("machine_disallowed_areas")
|
||||||
areas = []
|
areas = []
|
||||||
|
|
||||||
skirt_size = 0.0
|
skirt_size = 0.0
|
||||||
if self._active_profile:
|
skirt_size = self._getSkirtSize(self._active_container_stack)
|
||||||
skirt_size = self._getSkirtSize(self._active_profile)
|
|
||||||
|
|
||||||
if disallowed_areas:
|
if disallowed_areas:
|
||||||
# Extend every area already in the disallowed_areas with the skirt size.
|
# Extend every area already in the disallowed_areas with the skirt size.
|
||||||
|
@ -228,8 +214,8 @@ class BuildVolume(SceneNode):
|
||||||
|
|
||||||
# Add the skirt areas around the borders of the build plate.
|
# Add the skirt areas around the borders of the build plate.
|
||||||
if skirt_size > 0:
|
if skirt_size > 0:
|
||||||
half_machine_width = self._active_instance.getMachineSettingValue("machine_width") / 2
|
half_machine_width = self._active_container_stack.getValue("machine_width") / 2
|
||||||
half_machine_depth = self._active_instance.getMachineSettingValue("machine_depth") / 2
|
half_machine_depth = self._active_container_stack.getValue("machine_depth") / 2
|
||||||
|
|
||||||
areas.append(Polygon(numpy.array([
|
areas.append(Polygon(numpy.array([
|
||||||
[-half_machine_width, -half_machine_depth],
|
[-half_machine_width, -half_machine_depth],
|
||||||
|
@ -262,24 +248,24 @@ class BuildVolume(SceneNode):
|
||||||
self._disallowed_areas = areas
|
self._disallowed_areas = areas
|
||||||
|
|
||||||
## Convenience function to calculate the size of the bed adhesion.
|
## Convenience function to calculate the size of the bed adhesion.
|
||||||
def _getSkirtSize(self, profile):
|
def _getSkirtSize(self, container_stack):
|
||||||
skirt_size = 0.0
|
skirt_size = 0.0
|
||||||
|
|
||||||
adhesion_type = profile.getSettingValue("adhesion_type")
|
adhesion_type = container_stack.getValue("adhesion_type")
|
||||||
if adhesion_type == "skirt":
|
if adhesion_type == "skirt":
|
||||||
skirt_distance = profile.getSettingValue("skirt_gap")
|
skirt_distance = container_stack.getValue("skirt_gap")
|
||||||
skirt_line_count = profile.getSettingValue("skirt_line_count")
|
skirt_line_count = container_stack.getValue("skirt_line_count")
|
||||||
skirt_size = skirt_distance + (skirt_line_count * profile.getSettingValue("skirt_line_width"))
|
skirt_size = skirt_distance + (skirt_line_count * container_stack.getValue("skirt_line_width"))
|
||||||
elif adhesion_type == "brim":
|
elif adhesion_type == "brim":
|
||||||
skirt_size = profile.getSettingValue("brim_line_count") * profile.getSettingValue("skirt_line_width")
|
skirt_size = container_stack.getValue("brim_line_count") * container_stack.getValue("skirt_line_width")
|
||||||
elif adhesion_type == "raft":
|
elif adhesion_type == "raft":
|
||||||
skirt_size = profile.getSettingValue("raft_margin")
|
skirt_size = container_stack.getValue("raft_margin")
|
||||||
|
|
||||||
if profile.getSettingValue("draft_shield_enabled"):
|
if container_stack.getValue("draft_shield_enabled"):
|
||||||
skirt_size += profile.getSettingValue("draft_shield_dist")
|
skirt_size += container_stack.getValue("draft_shield_dist")
|
||||||
|
|
||||||
if profile.getSettingValue("xy_offset"):
|
if container_stack.getValue("xy_offset"):
|
||||||
skirt_size += profile.getSettingValue("xy_offset")
|
skirt_size += container_stack.getValue("xy_offset")
|
||||||
|
|
||||||
return skirt_size
|
return skirt_size
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue