From ab6a75c586abcf6f6abc009f251008e9b8c5c03a Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 29 Apr 2022 18:05:06 -0700 Subject: [PATCH] Adding hole processing to curve --- .../ApplicationView/SceneOperations.cs | 9 ++++-- .../DesignTools/Operations/CurveObject3D_3.cs | 28 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/MatterControlLib/ApplicationView/SceneOperations.cs b/MatterControlLib/ApplicationView/SceneOperations.cs index 70717fb50..e97516c40 100644 --- a/MatterControlLib/ApplicationView/SceneOperations.cs +++ b/MatterControlLib/ApplicationView/SceneOperations.cs @@ -677,11 +677,16 @@ namespace MatterHackers.MatterControl return new SceneOperation("Align") { OperationType = typeof(IObject3D), - ResultType = typeof(AlignObject3D_3), + ResultType = typeof(AlignObject3D_2), TitleGetter = () => "Align".Localize(), Action = (sceneContext) => { - new AlignObject3D_3().WrapSelectedItemAndSelect(sceneContext.Scene); + var scene = sceneContext.Scene; + var selectedItem = scene.SelectedItem; + var align = new AlignObject3D_2(); + align.AddSelectionAsChildren(scene, selectedItem); + align.Name = align.NameFromChildren(); + align.NameOverriden = false; }, Icon = (theme) => StaticData.Instance.LoadIcon("align_left_dark.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply(), HelpTextGetter = () => "At least 2 parts must be selected".Localize().Stars(), diff --git a/MatterControlLib/DesignTools/Operations/CurveObject3D_3.cs b/MatterControlLib/DesignTools/Operations/CurveObject3D_3.cs index 6d3306109..3d252b58a 100644 --- a/MatterControlLib/DesignTools/Operations/CurveObject3D_3.cs +++ b/MatterControlLib/DesignTools/Operations/CurveObject3D_3.cs @@ -31,6 +31,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Threading; using System.Threading.Tasks; using MatterHackers.Agg; @@ -39,6 +40,7 @@ using MatterHackers.DataConverters3D; using MatterHackers.Localizations; using MatterHackers.MatterControl.DesignTools.Operations; using MatterHackers.MatterControl.PartPreviewWindow; +using MatterHackers.MatterControl.PartPreviewWindow.View3D; using MatterHackers.PolygonMesh; using MatterHackers.RenderOpenGl; using MatterHackers.RenderOpenGl.OpenGl; @@ -351,6 +353,32 @@ namespace MatterHackers.MatterControl.DesignTools initialAabb.MinXYZ.Z - postAabb.MinXYZ.Z); } + var removeItems = Children.Where(c => c.OutputType == PrintOutputTypes.Hole && c.Visible); + if (removeItems.Any()) + { + var keepItems = Children.Where(c => c.OutputType != PrintOutputTypes.Hole && c.Visible); + + // apply any holes before we return + var resultItems = SubtractObject3D_2.DoSubtract(this, + keepItems, + removeItems, + reporter, + cancellationToken.Token); + + RemoveAllButSource(); + + // add back in the results of the hole removal + Children.Modify(list => + { + foreach (var child in resultItems) + { + list.Add(child); + child.Visible = true; + } + }); + } + + this.cancellationToken = null; UiThread.RunOnIdle(() => {