mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 11:25:53 +08:00
Merge pull request #18310 from Ultimaker/CURA-10542-drop_to_buildplate
Cura 10542 drop to buildplate
This commit is contained in:
commit
14ef281771
@ -1082,6 +1082,10 @@ class CuraApplication(QtApplication):
|
||||
def getTextManager(self, *args) -> "TextManager":
|
||||
return self._text_manager
|
||||
|
||||
@pyqtSlot(bool)
|
||||
def getWorkplaceDropToBuildplate(self, drop_to_build_plate: bool) ->None:
|
||||
return self._physics.setAppPerModelDropDown(drop_to_build_plate)
|
||||
|
||||
def getCuraFormulaFunctions(self, *args) -> "CuraFormulaFunctions":
|
||||
if self._cura_formula_functions is None:
|
||||
self._cura_formula_functions = CuraFormulaFunctions(self)
|
||||
|
@ -38,7 +38,14 @@ class PlatformPhysics:
|
||||
self._minimum_gap = 2 # It is a minimum distance (in mm) between two models, applicable for small models
|
||||
|
||||
Application.getInstance().getPreferences().addPreference("physics/automatic_push_free", False)
|
||||
Application.getInstance().getPreferences().addPreference("physics/automatic_drop_down", True)
|
||||
Application.getInstance().getPreferences().addPreference("physics/automatic_drop_down", False)
|
||||
self._app_per_model_drop = Application.getInstance().getPreferences().getValue("physics/automatic_drop_down")
|
||||
|
||||
def getAppPerModelDropDown(self):
|
||||
return self._app_per_model_drop
|
||||
|
||||
def setAppPerModelDropDown(self, drop_to_buildplate):
|
||||
self._app_per_model_drop = drop_to_buildplate
|
||||
|
||||
def _onSceneChanged(self, source):
|
||||
if not source.callDecoration("isSliceable"):
|
||||
@ -71,6 +78,7 @@ class PlatformPhysics:
|
||||
# We try to shuffle all the nodes to prevent "locked" situations, where iteration B inverts iteration A.
|
||||
# By shuffling the order of the nodes, this might happen a few times, but at some point it will resolve.
|
||||
random.shuffle(nodes)
|
||||
|
||||
for node in nodes:
|
||||
if node is root or not isinstance(node, SceneNode) or node.getBoundingBox() is None:
|
||||
continue
|
||||
@ -80,7 +88,10 @@ class PlatformPhysics:
|
||||
# Move it downwards if bottom is above platform
|
||||
move_vector = Vector()
|
||||
|
||||
if node.getSetting(SceneNodeSettings.AutoDropDown, app_automatic_drop_down) and not (node.getParent() and node.getParent().callDecoration("isGroup") or node.getParent() != root) and node.isEnabled(): #If an object is grouped, don't move it down
|
||||
# if per model drop is different then app_automatic_drop, in case of 3mf loading when user changes this setting for that model
|
||||
if (self._app_per_model_drop != app_automatic_drop_down):
|
||||
node.setSetting(SceneNodeSettings.AutoDropDown, self._app_per_model_drop)
|
||||
if node.getSetting(SceneNodeSettings.AutoDropDown, self._app_per_model_drop) and not (node.getParent() and node.getParent().callDecoration("isGroup") or node.getParent() != root) and node.isEnabled(): #If an object is grouped, don't move it down
|
||||
z_offset = node.callDecoration("getZOffset") if node.getDecorator(ZOffsetDecorator.ZOffsetDecorator) else 0
|
||||
move_vector = move_vector.set(y = -bbox.bottom + z_offset)
|
||||
|
||||
@ -168,6 +179,8 @@ class PlatformPhysics:
|
||||
op = PlatformPhysicsOperation.PlatformPhysicsOperation(node, move_vector)
|
||||
op.push()
|
||||
|
||||
# setting this drop to model same as app_automatic_drop_down
|
||||
self._app_per_model_drop = app_automatic_drop_down
|
||||
# After moving, we have to evaluate the boundary checks for nodes
|
||||
build_volume.updateNodeBoundaryCheck()
|
||||
|
||||
|
@ -299,6 +299,11 @@ class WorkspaceDialog(QObject):
|
||||
|
||||
Application.getInstance().getBackend().close()
|
||||
|
||||
@pyqtSlot(bool)
|
||||
def setDropToBuildPlateForModel(self, drop_to_buildplate: bool) -> None:
|
||||
CuraApplication.getInstance().getWorkplaceDropToBuildplate(drop_to_buildplate)
|
||||
|
||||
|
||||
def setMaterialConflict(self, material_conflict: bool) -> None:
|
||||
if self._has_material_conflict != material_conflict:
|
||||
self._has_material_conflict = material_conflict
|
||||
|
@ -300,6 +300,25 @@ UM.Dialog
|
||||
}
|
||||
}
|
||||
|
||||
Row
|
||||
{
|
||||
id: dropToBuildPlate
|
||||
width: parent.width
|
||||
height: childrenRect.height
|
||||
spacing: UM.Theme.getSize("default_margin").width
|
||||
UM.CheckBox
|
||||
{
|
||||
id: checkDropModels
|
||||
text: catalog.i18nc("@text:window", "Drop models to buildplate")
|
||||
checked: UM.Preferences.getValue("physics/automatic_drop_down")
|
||||
onCheckedChanged: manager.setDropToBuildPlateForModel(checked)
|
||||
}
|
||||
function reloadValue()
|
||||
{
|
||||
checkDropModels.checked = UM.Preferences.getValue("physics/automatic_drop_down")
|
||||
}
|
||||
}
|
||||
|
||||
Row
|
||||
{
|
||||
id: clearBuildPlateWarning
|
||||
@ -422,6 +441,7 @@ UM.Dialog
|
||||
materialSection.reloadValues()
|
||||
profileSection.reloadValues()
|
||||
printerSection.reloadValues()
|
||||
dropToBuildPlate.reloadValue()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -509,10 +509,13 @@ UM.PreferencesPage
|
||||
id: dropDownCheckbox
|
||||
text: catalog.i18nc("@option:check", "Automatically drop models to the build plate")
|
||||
checked: boolCheck(UM.Preferences.getValue("physics/automatic_drop_down"))
|
||||
onCheckedChanged: UM.Preferences.setValue("physics/automatic_drop_down", checked)
|
||||
onCheckedChanged:
|
||||
{
|
||||
UM.Preferences.setValue("physics/automatic_drop_down", checked)
|
||||
CuraApplication.getWorkplaceDropToBuildplate(checked)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UM.TooltipArea
|
||||
{
|
||||
|
@ -222,7 +222,7 @@ Item
|
||||
UM.Label
|
||||
{
|
||||
id: toolHint
|
||||
text: UM.Controller.properties.getValue("ToolHint") != undefined ? UM.ActiveTool.properties.getValue("ToolHint") : ""
|
||||
text: UM.Controller.properties.getValue("ToolHint") != undefined ? UM.Controller.properties.getValue("ToolHint") : ""
|
||||
color: UM.Theme.getColor("tooltip_text")
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user