improved arrange all

accelerated tree view rebuild
This commit is contained in:
LarsBrubaker 2020-08-01 23:24:19 -07:00
parent 45178b1baf
commit ed1626169b
3 changed files with 23 additions and 29 deletions

View file

@ -506,8 +506,8 @@ namespace MatterHackers.MatterControl.CustomWidgets
public TreeExpandWidget(ThemeConfig theme)
{
arrowRight = AggContext.StaticData.LoadIcon("fa-angle-right_12.png", theme.InvertIcons);
arrowDown = AggContext.StaticData.LoadIcon("fa-angle-down_12.png", theme.InvertIcons);
arrowRight = AggContext.StaticData.LoadIcon("fa-angle-right_12.png", 12, 12, theme.InvertIcons);
arrowDown = AggContext.StaticData.LoadIcon("fa-angle-down_12.png", 12, 12, theme.InvertIcons);
placeholder = new ImageBuffer(16, 16);
this.Margin = new BorderDouble(right: 4);

View file

@ -169,6 +169,11 @@ namespace MatterHackers.MatterControl
/// <param name="itemsToAvoid">The objects to hit test against</param>
public static void MoveToOpenPosition(IObject3D itemToMove, IEnumerable<IObject3D> itemsToAvoid)
{
if (itemToMove == null)
{
return;
}
// find a place to put it that doesn't hit anything
var currentBounds = itemToMove.GetAxisAlignedBoundingBox();
var itemToMoveBounds = new AxisAlignedBoundingBox(currentBounds.MinXYZ, currentBounds.MaxXYZ);
@ -178,32 +183,16 @@ namespace MatterHackers.MatterControl
itemToMoveBounds.MaxXYZ += new Vector3(2, 2, 0);
var transform = Matrix4X4.Identity;
int currentSize = 1;
bool partPlaced = false;
while (!partPlaced && itemToMove != null)
while (!partPlaced)
{
int xStep = 0;
int yStep;
// check far right edge
for (yStep = 0; yStep < currentSize; yStep++)
int distance = 0;
while (!partPlaced)
{
partPlaced = CheckPosition(itemsToAvoid, itemToMove, itemToMoveBounds, yStep, xStep, ref transform);
if (partPlaced)
for (int i = 0; i <= distance; i++)
{
break;
}
}
if (!partPlaced)
{
yStep = currentSize;
// check top edge
for (xStep = 0; xStep < currentSize; xStep++)
{
partPlaced = CheckPosition(itemsToAvoid, itemToMove, itemToMoveBounds, yStep, xStep, ref transform);
partPlaced = CheckPosition(itemsToAvoid, itemToMove, itemToMoveBounds, i, distance, ref transform);
if (partPlaced)
{
break;
@ -212,13 +201,18 @@ namespace MatterHackers.MatterControl
if (!partPlaced)
{
xStep = currentSize;
// check top right point
partPlaced = CheckPosition(itemsToAvoid, itemToMove, itemToMoveBounds, yStep, xStep, ref transform);
for (int i = 0; i <= distance; i++)
{
partPlaced = CheckPosition(itemsToAvoid, itemToMove, itemToMoveBounds, distance, i, ref transform);
if (partPlaced)
{
break;
}
}
}
}
currentSize++;
distance++;
}
}
itemToMove.Matrix *= transform;

@ -1 +1 @@
Subproject commit 2cb100544bc6d6ae35086cc2a3592272d7323f12
Subproject commit a92de4a6564997977e9a61c4780ce221898c9615