improving support generator

can undo remove supports
starting work on not overlapping existing support
working on support tests
cleaned up delete command (use selection maintainer)
This commit is contained in:
LarsBrubaker 2019-01-31 07:56:36 -08:00
parent efe0255238
commit 1918d5987a
5 changed files with 95 additions and 49 deletions

View file

@ -42,60 +42,58 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public DeleteCommand(InteractiveScene scene, IObject3D deletingItem)
{
this.scene = scene;
if (deletingItem is SelectionGroupObject3D)
{
var childrenToAdd = deletingItem.Children;
// push whatever happened to the selection into the objects before saving them
scene.ClearSelection();
// save them in our list
foreach (var item in childrenToAdd)
{
items.Add(item);
}
SetDeletionObjects(scene, deletingItem.Children);
}
else
{
this.items.Add(deletingItem);
SetDeletionObjects(scene, new IObject3D[] { deletingItem });
}
}
public DeleteCommand(InteractiveScene scene, IEnumerable<IObject3D> deletingItems)
{
SetDeletionObjects(scene, deletingItems);
}
private void SetDeletionObjects(InteractiveScene scene, IEnumerable<IObject3D> deletingItems)
{
this.scene = scene;
scene.ClearSelection();
// save them in our list
foreach (var item in deletingItems)
{
items.Add(item);
}
}
public void Do()
{
scene.ClearSelection();
scene.Children.Modify(list =>
using (new SelectionMaintainer(scene))
{
foreach (var item in items)
scene.Children.Modify(list =>
{
list.Remove(item);
}
});
scene.SelectLastChild();
scene.Invalidate(new InvalidateArgs(null, InvalidateType.Children));
foreach (var item in items)
{
list.Remove(item);
}
});
}
}
public void Undo()
{
scene.Children.Modify(list =>
using (new SelectionMaintainer(scene))
{
foreach (var item in items)
scene.Children.Modify(list =>
{
list.Add(item);
}
});
scene.ClearSelection();
foreach (var item in items)
{
scene.AddToSelection(item);
foreach (var item in items)
{
list.Add(item);
}
});
}
scene.Invalidate(new InvalidateArgs(null, InvalidateType.Children));
}
}
}