mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 15:35:54 +08:00
Merge branch 'master' of https://github.com/Ultimaker/Cura
This commit is contained in:
commit
326bb0f1f3
@ -4,6 +4,7 @@
|
|||||||
from cura.Settings.ExtruderManager import ExtruderManager
|
from cura.Settings.ExtruderManager import ExtruderManager
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
from UM.Scene.Platform import Platform
|
from UM.Scene.Platform import Platform
|
||||||
|
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
|
||||||
from UM.Scene.SceneNode import SceneNode
|
from UM.Scene.SceneNode import SceneNode
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Resources import Resources
|
from UM.Resources import Resources
|
||||||
@ -14,7 +15,7 @@ from UM.Math.AxisAlignedBox import AxisAlignedBox
|
|||||||
from UM.Math.Polygon import Polygon
|
from UM.Math.Polygon import Polygon
|
||||||
from UM.Message import Message
|
from UM.Message import Message
|
||||||
from UM.Signal import Signal
|
from UM.Signal import Signal
|
||||||
|
from PyQt5.QtCore import QTimer
|
||||||
from UM.View.RenderBatch import RenderBatch
|
from UM.View.RenderBatch import RenderBatch
|
||||||
from UM.View.GL.OpenGL import OpenGL
|
from UM.View.GL.OpenGL import OpenGL
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
@ -84,6 +85,29 @@ class BuildVolume(SceneNode):
|
|||||||
self._onGlobalContainerStackChanged()
|
self._onGlobalContainerStackChanged()
|
||||||
|
|
||||||
self._has_errors = False
|
self._has_errors = False
|
||||||
|
Application.getInstance().getController().getScene().sceneChanged.connect(self._onSceneChanged)
|
||||||
|
|
||||||
|
# Number of objects loaded at the moment.
|
||||||
|
self._number_of_objects = 0
|
||||||
|
|
||||||
|
self._change_timer = QTimer()
|
||||||
|
self._change_timer.setInterval(100)
|
||||||
|
self._change_timer.setSingleShot(True)
|
||||||
|
self._change_timer.timeout.connect(self._onChangeTimerFinished)
|
||||||
|
|
||||||
|
def _onSceneChanged(self, source):
|
||||||
|
self._change_timer.start()
|
||||||
|
|
||||||
|
def _onChangeTimerFinished(self):
|
||||||
|
root = Application.getInstance().getController().getScene().getRoot()
|
||||||
|
new_number_of_objects = len([node for node in BreadthFirstIterator(root) if node.getMeshData() and type(node) is SceneNode])
|
||||||
|
if new_number_of_objects != self._number_of_objects:
|
||||||
|
recalculate = False
|
||||||
|
if self._global_container_stack.getProperty("print_sequence", "value") == "one_at_a_time":
|
||||||
|
recalculate = (new_number_of_objects < 2 and self._number_of_objects > 1) or (new_number_of_objects > 1 and self._number_of_objects < 2)
|
||||||
|
self._number_of_objects = new_number_of_objects
|
||||||
|
if recalculate:
|
||||||
|
self._onSettingPropertyChanged("print_sequence", "value") # Create fake event, so right settings are triggered.
|
||||||
|
|
||||||
def setWidth(self, width):
|
def setWidth(self, width):
|
||||||
if width: self._width = width
|
if width: self._width = width
|
||||||
@ -272,7 +296,7 @@ class BuildVolume(SceneNode):
|
|||||||
|
|
||||||
self._width = self._global_container_stack.getProperty("machine_width", "value")
|
self._width = self._global_container_stack.getProperty("machine_width", "value")
|
||||||
machine_height = self._global_container_stack.getProperty("machine_height", "value")
|
machine_height = self._global_container_stack.getProperty("machine_height", "value")
|
||||||
if self._global_container_stack.getProperty("print_sequence", "value") == "one_at_a_time":
|
if self._global_container_stack.getProperty("print_sequence", "value") == "one_at_a_time" and self._number_of_objects > 1:
|
||||||
self._height = min(self._global_container_stack.getProperty("gantry_height", "value"), machine_height)
|
self._height = min(self._global_container_stack.getProperty("gantry_height", "value"), machine_height)
|
||||||
if self._height < machine_height:
|
if self._height < machine_height:
|
||||||
self._buildVolumeMessage()
|
self._buildVolumeMessage()
|
||||||
@ -292,7 +316,7 @@ class BuildVolume(SceneNode):
|
|||||||
rebuild_me = False
|
rebuild_me = False
|
||||||
if setting_key == "print_sequence":
|
if setting_key == "print_sequence":
|
||||||
machine_height = self._global_container_stack.getProperty("machine_height", "value")
|
machine_height = self._global_container_stack.getProperty("machine_height", "value")
|
||||||
if Application.getInstance().getGlobalContainerStack().getProperty("print_sequence", "value") == "one_at_a_time":
|
if Application.getInstance().getGlobalContainerStack().getProperty("print_sequence", "value") == "one_at_a_time" and self._number_of_objects > 1:
|
||||||
self._height = min(self._global_container_stack.getProperty("gantry_height", "value"), machine_height)
|
self._height = min(self._global_container_stack.getProperty("gantry_height", "value"), machine_height)
|
||||||
if self._height < machine_height:
|
if self._height < machine_height:
|
||||||
self._buildVolumeMessage()
|
self._buildVolumeMessage()
|
||||||
|
@ -55,21 +55,30 @@ 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):
|
if not settings.getInstance(item): # 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)
|
||||||
stack_nr = -1
|
stack_nr = -1
|
||||||
if definition.limit_to_extruder and self._stack.getProperty("machine_extruder_count", "value") > 1:
|
stack = None
|
||||||
#Obtain the value from the correct container stack. Only once, upon adding the setting.
|
# Check from what stack we should copy the raw property of the setting from.
|
||||||
stack_nr = str(int(round(float(self._stack.getProperty(item, "limit_to_extruder"))))) #Stack to get the setting from. Round it and remove the fractional part.
|
if definition.limit_to_extruder != "-1" and self._stack.getProperty("machine_extruder_count", "value") > 1:
|
||||||
if stack_nr not in ExtruderManager.getInstance().extruderIds and self._stack.getProperty("extruder_nr", "value"): #Property not defined, but we have an extruder number.
|
# A limit to extruder function was set and it's a multi extrusion machine. Check what stack we do need to use.
|
||||||
stack_nr = str(int(round(float(self._stack.getProperty("extruder_nr", "value")))))
|
stack_nr = str(int(round(float(self._stack.getProperty(item, "limit_to_extruder")))))
|
||||||
if stack_nr in ExtruderManager.getInstance().extruderIds: #We have either a limit_to_extruder or an extruder_nr.
|
|
||||||
stack = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id = ExtruderManager.getInstance().extruderIds[stack_nr])[0]
|
# Check if the found stack_number is in the extruder list of extruders.
|
||||||
|
if stack_nr not in ExtruderManager.getInstance().extruderIds and self._stack.getProperty("extruder_nr", "value") is not None:
|
||||||
|
stack_nr = -1
|
||||||
|
|
||||||
|
# Use the found stack number to get the right stack to copy the value from.
|
||||||
|
if stack_nr in ExtruderManager.getInstance().extruderIds:
|
||||||
|
stack = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id=ExtruderManager.getInstance().extruderIds[stack_nr])[0]
|
||||||
|
|
||||||
|
# Use the raw property to set the value (so the intheritance doesn't break)
|
||||||
|
if stack is not None:
|
||||||
|
new_instance.setProperty("value", stack.getRawProperty(item, "value"))
|
||||||
else:
|
else:
|
||||||
stack = UM.Application.getInstance().getGlobalContainerStack()
|
new_instance.setProperty("value", None)
|
||||||
new_instance.setProperty("value", stack.getRawProperty(item, "value"))
|
|
||||||
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)
|
||||||
visibility_changed = True
|
visibility_changed = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user