introducing drop to buildplate per model

CURA-10542
This commit is contained in:
saumya.jain 2024-02-09 10:32:39 +01:00
parent 578057f16a
commit e8bdca3dd9
3 changed files with 79 additions and 4 deletions

View File

@ -38,7 +38,7 @@ 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_per_model", "never")
def _onSceneChanged(self, source):
if not source.callDecoration("isSliceable"):
@ -71,6 +71,15 @@ 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)
default_value = False
if app_automatic_drop_down == "always":
default_value = True
if app_automatic_drop_down == "never":
default_value = False
if app_automatic_drop_down == "always_ask":
# ask_during_loading_model
pass
for node in nodes:
if node is root or not isinstance(node, SceneNode) or node.getBoundingBox() is None:
continue
@ -80,10 +89,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 node.getSetting(SceneNodeSettings.AutoDropDown, default_value) 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)
# If there is no convex hull for the node, start calculating it and continue.
if not node.getDecorator(ConvexHullDecorator) and not node.callDecoration("isNonPrintingMesh") and node.callDecoration("getLayerData") is None:
node.addDecorator(ConvexHullDecorator())

View File

@ -63,6 +63,18 @@ UM.PreferencesPage
}
}
function setDefaultDropDown(code)
{
for (var i = 0; i < choiceOnDropDown.model.count; ++i)
{
if (choiceOnDropDown.model.get(i).code == code)
{
choiceOnDropDown.currentIndex = i
break;
}
}
}
function reset()
{
UM.Preferences.resetPreference("general/language")
@ -513,6 +525,60 @@ UM.PreferencesPage
}
}
UM.TooltipArea
{
width: childrenRect.width
height: childrenRect.height
text: catalog.i18nc("@info:tooltip", "This setting will set a default (or not) for the Per Model Drop to buildplate feature (Either Always, Never, decide every time")
Column
{
spacing: UM.Theme.getSize("narrow_margin").height
UM.Label
{
text: catalog.i18nc("@window:text", " Default per model setting for drop to build plate when importing a model: ")
}
Cura.ComboBox
{
id: choiceOnDropDown
width: UM.Theme.getSize("combobox").width
height: UM.Theme.getSize("combobox").height
model: ListModel
{
id: dropDownOptions
Component.onCompleted:
{
append({ text: catalog.i18nc("@option:openProject", "Always"), code: "always" })
append({ text: catalog.i18nc("@option:openProject", "Never"), code: "never" })
append({ text: catalog.i18nc("@option:openProject", "Always ask me this"), code: "always_ask" })
}
}
textRole: "text"
currentIndex:
{
var index = 0;
var currentChoice = UM.Preferences.getValue("physics/automatic_drop_down_per_model");
for (var i = 0; i < model.count; ++i)
{
if (model.get(i).code == currentChoice)
{
index = i;
break;
}
}
return index;
}
onActivated: UM.Preferences.setValue("physics/automatic_drop_down_per_model", model.get(index).code)
}
}
}
UM.TooltipArea
{

View File

@ -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
}