preference does not change after user changes drop to buildplate for a model

CURA-10542
This commit is contained in:
saumya.jain 2024-02-14 12:59:41 +01:00
parent aa2abfbd2e
commit 32d9e6b45c
2 changed files with 19 additions and 3 deletions

View file

@ -39,6 +39,7 @@ class PlatformPhysics:
Application.getInstance().getPreferences().addPreference("physics/automatic_push_free", False) Application.getInstance().getPreferences().addPreference("physics/automatic_push_free", False)
Application.getInstance().getPreferences().addPreference("physics/automatic_drop_down", False) Application.getInstance().getPreferences().addPreference("physics/automatic_drop_down", False)
Application.getInstance().getPreferences().addPreference("physics/per_model_drop", False)
def _onSceneChanged(self, source): def _onSceneChanged(self, source):
if not source.callDecoration("isSliceable"): if not source.callDecoration("isSliceable"):
@ -54,6 +55,9 @@ class PlatformPhysics:
app_preferences = app_instance.getPreferences() app_preferences = app_instance.getPreferences()
app_automatic_drop_down = app_preferences.getValue("physics/automatic_drop_down") app_automatic_drop_down = app_preferences.getValue("physics/automatic_drop_down")
app_automatic_push_free = app_preferences.getValue("physics/automatic_push_free") app_automatic_push_free = app_preferences.getValue("physics/automatic_push_free")
# silent preference setting to mimic preference automatic_drop_down only different when user changes it explicitely while opening model
app_per_model_drop = app_preferences.getValue("physics/per_model_drop")
root = self._controller.getScene().getRoot() root = self._controller.getScene().getRoot()
build_volume = app_instance.getBuildVolume() build_volume = app_instance.getBuildVolume()
@ -81,7 +85,11 @@ class PlatformPhysics:
# Move it downwards if bottom is above platform # Move it downwards if bottom is above platform
move_vector = Vector() 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 (app_per_model_drop != app_automatic_drop_down):
node.setSetting(SceneNodeSettings.AutoDropDown, app_per_model_drop)
if node.getSetting(SceneNodeSettings.AutoDropDown, 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 z_offset = node.callDecoration("getZOffset") if node.getDecorator(ZOffsetDecorator.ZOffsetDecorator) else 0
move_vector = move_vector.set(y = -bbox.bottom + z_offset) move_vector = move_vector.set(y = -bbox.bottom + z_offset)
@ -169,6 +177,8 @@ class PlatformPhysics:
op = PlatformPhysicsOperation.PlatformPhysicsOperation(node, move_vector) op = PlatformPhysicsOperation.PlatformPhysicsOperation(node, move_vector)
op.push() op.push()
# setting this silent preference same as app_automatic_drop_down
app_preferences.setValue("physics/per_model_drop", app_automatic_drop_down)
# After moving, we have to evaluate the boundary checks for nodes # After moving, we have to evaluate the boundary checks for nodes
build_volume.updateNodeBoundaryCheck() build_volume.updateNodeBoundaryCheck()

View file

@ -308,9 +308,14 @@ UM.Dialog
spacing: UM.Theme.getSize("default_margin").width spacing: UM.Theme.getSize("default_margin").width
UM.CheckBox UM.CheckBox
{ {
id: checkDropModels
text: catalog.i18nc("@text:window", "Drop models to buildplate") text: catalog.i18nc("@text:window", "Drop models to buildplate")
checked: UM.Preferences.getValue("physics/automatic_drop_down") == True checked: UM.Preferences.getValue("physics/automatic_drop_down")
onCheckedChanged: UM.Preferences.setValue("physics/automatic_drop_down", checked) onCheckedChanged: UM.Preferences.setValue("physics/per_model_drop", checked)
}
function reloadValue()
{
checkDropModels.checked = UM.Preferences.getValue("physics/automatic_drop_down")
} }
} }
@ -436,6 +441,7 @@ UM.Dialog
materialSection.reloadValues() materialSection.reloadValues()
profileSection.reloadValues() profileSection.reloadValues()
printerSection.reloadValues() printerSection.reloadValues()
dropToBuildPlate.reloadValue()
} }
} }
} }