From a216a484bb0edf0d493cf2003ac0c61e2478225a Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Sun, 10 Apr 2022 16:35:13 -0700 Subject: [PATCH 1/4] fix parsing of bad bounds --- .../View3D/Actions/CombineObject3D_2.cs | 21 ++++++++++--------- .../View3D/Actions/SubtractObject3D_2.cs | 2 +- .../PartPreviewWindow/View3D/View3DWidget.cs | 5 ++++- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs index c1d57c535..b8b264048 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs @@ -147,15 +147,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D var totalOperations = touchingSets.Sum(t => t.Count); -#if false - var resultsMesh = BooleanProcessing.DoArray(items, - CsgModes.Union, - Processing, - InputResolution, - OutputResolution, - reporter, - cancellationToken); -#else double amountPerOperation = 1.0 / totalOperations; double ratioCompleted = 0; @@ -169,6 +160,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D if (set.Count > 1) { +#if false + setMesh = BooleanProcessing.DoArray(set.Select(i => (i.mesh, i.matrix)), + CsgModes.Union, + Processing, + InputResolution, + OutputResolution, + reporter, + cancellationToken); +#else + bool first = true; foreach (var next in set) { @@ -203,6 +204,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D progressStatus.Progress0To1 = ratioCompleted; reporter?.Report(progressStatus); } +#endif setMeshes.Add(setMesh); } @@ -229,7 +231,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D resultsMesh.CopyAllFaces(setMesh, Matrix4X4.Identity); } } -#endif if (resultsMesh != null) { diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs index 9d7dcbaf9..22135eb91 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs @@ -257,7 +257,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D foreach (var keep in keepItems) { #if false - var items = removeVisibleItems.Select(i => (i.Mesh, i.WorldMatrix(SourceContainer))).ToList(); + var items = removeItems.Select(i => (i.Mesh, i.WorldMatrix(SourceContainer))).ToList(); items.Insert(0, (keep.Mesh, keep.Matrix)); var resultsMesh = BooleanProcessing.DoArray(items, CsgModes.Subtract, diff --git a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs index 9cd362eef..bdf58848b 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs @@ -748,7 +748,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Tuple nearFar = null; foreach (var aabb in Object3DControlLayer.MakeListOfObjectControlBoundingBoxes()) { - nearFar = ExpandNearAndFarToClippedBounds(nearFar, world.IsOrthographic, worldspacePlanes, world.ModelviewMatrix, aabb); + if (!double.IsNaN(aabb.MinXYZ.X) && !double.IsInfinity(aabb.MinXYZ.X)) + { + nearFar = ExpandNearAndFarToClippedBounds(nearFar, world.IsOrthographic, worldspacePlanes, world.ModelviewMatrix, aabb); + } } nearFar = ExpandNearAndFarToClippedBounds(nearFar, world.IsOrthographic, worldspacePlanes, world.ModelviewMatrix, Object3DControlLayer.GetPrinterNozzleAABB()); nearFar = ExpandNearAndFarToClippedBounds(nearFar, world.IsOrthographic, worldspacePlanes, world.ModelviewMatrix, Scene.GetAxisAlignedBoundingBox()); From 094324e645f58ab931a97ec5df64a06e73a60f69 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Thu, 28 Apr 2022 11:08:22 -0700 Subject: [PATCH 2/4] Improving matterslice output in consideration of top level holes --- .../EngineMappingsMatterSlice.cs | 93 +++++++++++++------ .../SlicerConfiguration/Slicer.cs | 35 +++++-- Submodules/MatterSlice | 2 +- Submodules/agg-sharp | 2 +- 4 files changed, 92 insertions(+), 40 deletions(-) diff --git a/MatterControlLib/SlicerConfiguration/EngineMappingsMatterSlice.cs b/MatterControlLib/SlicerConfiguration/EngineMappingsMatterSlice.cs index 36984a012..5f86e2356 100644 --- a/MatterControlLib/SlicerConfiguration/EngineMappingsMatterSlice.cs +++ b/MatterControlLib/SlicerConfiguration/EngineMappingsMatterSlice.cs @@ -294,7 +294,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration for (int extruderIndexIn = 0; extruderIndexIn < extruderCount; extruderIndexIn++) { var extruderIndex = extruderIndexIn; - IEnumerable itemsThisExtruder = Slicer.GetItemsForExtruder(meshItemsOnBuildPlate, extruderCount, extruderIndex, true); + IEnumerable itemsThisExtruder = Slicer.GetSolidsForExtruder(meshItemsOnBuildPlate, extruderCount, extruderIndex, true); itemsByExtruder.Add(itemsThisExtruder); if (Slicer.ExtrudersUsed[extruderIndex]) @@ -305,17 +305,18 @@ namespace MatterHackers.MatterControl.SlicerConfiguration var outputOptions = new List<(Matrix4X4 matrix, string fileName)>(); + var holes = Slicer.GetAllHoles(meshItemsOnBuildPlate); + int savedStlCount = 0; - bool first = true; + var firstExtruder = true; for (int extruderIndex = 0; extruderIndex < itemsByExtruder.Count; extruderIndex++) { - if (!first) + if (!firstExtruder) { mergeRules += ","; - first = false; } - - mergeRules += AddObjectsForExtruder(itemsByExtruder[extruderIndex], outputOptions, ref savedStlCount); + mergeRules += AddObjectsForExtruder(itemsByExtruder[extruderIndex], holes, outputOptions, ref savedStlCount); + firstExtruder = false; } var supportObjects = meshItemsOnBuildPlate.Where((item) => item.WorldOutputType() == PrintOutputTypes.Support); @@ -323,7 +324,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration if (supportObjects.Any()) { // add a flag to the merge rules to let us know there was support - mergeRules += ",S" + AddObjectsForExtruder(supportObjects, outputOptions, ref savedStlCount); + mergeRules += "S" + AddObjectsForExtruder(supportObjects, holes, outputOptions, ref savedStlCount); } var wipeTowerObjects = meshItemsOnBuildPlate.Where((item) => item.WorldOutputType() == PrintOutputTypes.WipeTower); @@ -331,7 +332,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration if (wipeTowerObjects.Any()) { // add a flag to the merge rules to let us know there was a wipe tower - mergeRules += ",W" + AddObjectsForExtruder(wipeTowerObjects, outputOptions, ref savedStlCount); + mergeRules += "W" + AddObjectsForExtruder(wipeTowerObjects, holes, outputOptions, ref savedStlCount); } var fuzzyObjects = meshItemsOnBuildPlate.Where((item) => item.WorldOutputType() == PrintOutputTypes.Fuzzy); @@ -339,11 +340,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration if (fuzzyObjects.Any()) { // add a flag to the merge rules to let us know there was a wipe tower - mergeRules += ",F" + AddObjectsForExtruder(fuzzyObjects, outputOptions, ref savedStlCount); + mergeRules += "F" + AddObjectsForExtruder(fuzzyObjects, holes, outputOptions, ref savedStlCount); } - mergeRules += " "; - return outputOptions; } @@ -600,36 +599,70 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } } - private static string AddObjectsForExtruder(IEnumerable items, List<(Matrix4X4 matrix, string fileName)> outputItems, ref int savedStlCount) + private static string AddObjectsForExtruder(IEnumerable solids, IEnumerable holes, List<(Matrix4X4 matrix, string fileName)> outputItems, ref int savedStlCount) { string mergeString = ""; - if (items.Any()) + if (solids.Any()) { - bool first = true; - foreach (var item in items) + bool firstSolid = true; + foreach (var solid in solids) { - if (!first) - { - mergeString += ","; - } - - var itemWorldMatrix = item.WorldMatrix(); - if (item is GeneratedSupportObject3D generatedSupportObject3D - && item.Mesh != null) + var itemWorldMatrix = solid.WorldMatrix(); + if (solid is GeneratedSupportObject3D generatedSupportObject3D + && solid.Mesh != null) { // grow the support columns by the amount they are reduced by - var aabbForCenter = item.Mesh.GetAxisAlignedBoundingBox(); - var aabbForSize = item.Mesh.GetAxisAlignedBoundingBox(item.Matrix); + var aabbForCenter = solid.Mesh.GetAxisAlignedBoundingBox(); + var aabbForSize = solid.Mesh.GetAxisAlignedBoundingBox(solid.Matrix); var xyScale = (aabbForSize.XSize + 2 * SupportGenerator.ColumnReduceAmount) / aabbForSize.XSize; itemWorldMatrix = itemWorldMatrix.ApplyAtPosition(aabbForCenter.Center.Transform(itemWorldMatrix), Matrix4X4.CreateScale(xyScale, xyScale, 1)); } - outputItems.Add((itemWorldMatrix, Path.Combine(ApplicationDataStorage.Instance.LibraryAssetsPath, item.MeshPath))); - mergeString += $"({savedStlCount++}"; - first = false; + outputItems.Add((itemWorldMatrix, Path.Combine(ApplicationDataStorage.Instance.LibraryAssetsPath, solid.MeshPath))); + mergeString += $"{savedStlCount++}"; + if (solids.Count() > 1) + { + if (firstSolid) + { + mergeString += ","; + firstSolid = false; + } + else + { + mergeString += "+"; + } + } + else if (holes.Any()) + { + mergeString += ","; + } } - mergeString += new string(')', items.Count()); + if (holes.Any()) + { + bool firstHole = true; + + foreach (var hole in holes) + { + var itemWorldMatrix = hole.WorldMatrix(); + outputItems.Add((itemWorldMatrix, Path.Combine(ApplicationDataStorage.Instance.LibraryAssetsPath, hole.MeshPath))); + mergeString += $"{savedStlCount++}"; + if (holes.Count() > 1) + { + if (firstHole) + { + mergeString += ","; + firstHole = false; + } + else + { + mergeString += "+"; + } + } + } + + mergeString += "-"; + } } else { @@ -646,7 +679,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration StlProcessing.Save(tinyMesh, tinyObjectFileName, CancellationToken.None); outputItems.Add((Matrix4X4.Identity, tinyObjectFileName)); - mergeString += $"({savedStlCount++})"; + mergeString += $"{savedStlCount++}"; } return mergeString; diff --git a/MatterControlLib/SlicerConfiguration/Slicer.cs b/MatterControlLib/SlicerConfiguration/Slicer.cs index 8cdc6db7d..cb1594aa0 100644 --- a/MatterControlLib/SlicerConfiguration/Slicer.cs +++ b/MatterControlLib/SlicerConfiguration/Slicer.cs @@ -95,7 +95,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration for (int extruderIndex = 0; extruderIndex < extruderCount; extruderIndex++) { - IEnumerable itemsThisExtruder = GetItemsForExtruder(printableItems, extruderCount, extruderIndex, checkForMeshFile); + IEnumerable itemsThisExtruder = GetSolidsForExtruder(printableItems, extruderCount, extruderIndex, checkForMeshFile); extrudersUsed[extruderIndex] |= itemsThisExtruder.Any(); } } @@ -118,15 +118,34 @@ namespace MatterHackers.MatterControl.SlicerConfiguration return false; } - public static IEnumerable GetItemsForExtruder(IEnumerable meshItemsOnBuildPlate, int extruderCount, int extruderIndex, bool checkForMeshFile) + public static IEnumerable GetSolidsForExtruder(IEnumerable meshItemsOnBuildPlate, int extruderCount, int extruderIndex, bool checkForMeshFile) { var itemsThisExtruder = meshItemsOnBuildPlate.Where((item) => - (!checkForMeshFile || (File.Exists(item.MeshPath) // Drop missing files - || File.Exists(Path.Combine(Object3D.AssetsPath, item.MeshPath)))) - && (item.WorldMaterialIndex() == extruderIndex - || (extruderIndex == 0 - && (item.WorldMaterialIndex() >= extruderCount || item.WorldMaterialIndex() == -1))) - && (item.WorldOutputType() == PrintOutputTypes.Solid || item.WorldOutputType() == PrintOutputTypes.Default)); + { + var outputType = item.WorldOutputType(); + var material = item.WorldMaterialIndex(); + + return (!checkForMeshFile + || File.Exists(item.MeshPath) // Drop missing files + || File.Exists(Path.Combine(Object3D.AssetsPath, item.MeshPath))) + && (material == extruderIndex || (extruderIndex == 0 && (material >= extruderCount || material == -1))) + && (outputType == PrintOutputTypes.Solid || outputType == PrintOutputTypes.Default); + }); + + return itemsThisExtruder; + } + + public static IEnumerable GetAllHoles(IEnumerable meshItemsOnBuildPlate) + { + var itemsThisExtruder = meshItemsOnBuildPlate.Where((item) => + { + var outputType = item.WorldOutputType(); + var material = item.WorldMaterialIndex(); + + return (File.Exists(item.MeshPath) // Drop missing files + || File.Exists(Path.Combine(Object3D.AssetsPath, item.MeshPath))) + && outputType == PrintOutputTypes.Hole; + }); return itemsThisExtruder; } diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index e754c8142..9578a32e7 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit e754c81428db89bb94fadac23f026de7579bff8f +Subproject commit 9578a32e7032236c2ff7fc1a588c6d099eec333d diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 444ce5470..9e115e537 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 444ce54704973489addef582e27353a0f84b59ac +Subproject commit 9e115e5373d44f9cc7fdcee0e3290b1e88c39970 From cf5931d2722843cfd209ac49ec26539fa1516085 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Thu, 28 Apr 2022 13:19:48 -0700 Subject: [PATCH 3/4] Improving ShowUpdateButton api --- .../DesignTools/Attributes/ShowUpdateButtonAttribute.cs | 6 +++--- MatterControlLib/DesignTools/LithophaneObject3D.cs | 2 +- MatterControlLib/DesignTools/PublicPropertyEditor.cs | 3 ++- .../PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs | 2 +- .../View3D/Actions/IntersectionObject3D_2.cs | 2 +- .../View3D/Actions/SubtractAndReplaceObject3D.cs | 2 +- .../View3D/Actions/SubtractAndReplaceObject3D_2.cs | 2 +- .../PartPreviewWindow/View3D/Actions/SubtractObject3D.cs | 2 +- .../PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs | 2 +- Submodules/MatterSlice | 2 +- 10 files changed, 13 insertions(+), 12 deletions(-) diff --git a/MatterControlLib/DesignTools/Attributes/ShowUpdateButtonAttribute.cs b/MatterControlLib/DesignTools/Attributes/ShowUpdateButtonAttribute.cs index 4ee3362db..677480ff8 100644 --- a/MatterControlLib/DesignTools/Attributes/ShowUpdateButtonAttribute.cs +++ b/MatterControlLib/DesignTools/Attributes/ShowUpdateButtonAttribute.cs @@ -34,11 +34,11 @@ namespace MatterHackers.MatterControl.DesignTools [AttributeUsage(AttributeTargets.Class)] public class ShowUpdateButtonAttribute : Attribute { - public bool SuppressPropertyChangeUpdates { get; set; } + public bool Show { get; set; } = true; + public bool SuppressPropertyChangeUpdates { get; set; } - public ShowUpdateButtonAttribute(bool suppressPropertyChangeUpdates) + public ShowUpdateButtonAttribute() { - SuppressPropertyChangeUpdates = suppressPropertyChangeUpdates; } } } \ No newline at end of file diff --git a/MatterControlLib/DesignTools/LithophaneObject3D.cs b/MatterControlLib/DesignTools/LithophaneObject3D.cs index dab12d8d1..31d6b1571 100644 --- a/MatterControlLib/DesignTools/LithophaneObject3D.cs +++ b/MatterControlLib/DesignTools/LithophaneObject3D.cs @@ -44,7 +44,7 @@ using Newtonsoft.Json; namespace MatterHackers.MatterControl.Plugins.Lithophane { - [ShowUpdateButton(true)] + [ShowUpdateButton(SuppressPropertyChangeUpdates = true)] public class LithophaneObject3D : Object3D { public LithophaneObject3D() diff --git a/MatterControlLib/DesignTools/PublicPropertyEditor.cs b/MatterControlLib/DesignTools/PublicPropertyEditor.cs index a06e218ce..96755e9e9 100644 --- a/MatterControlLib/DesignTools/PublicPropertyEditor.cs +++ b/MatterControlLib/DesignTools/PublicPropertyEditor.cs @@ -159,7 +159,8 @@ namespace MatterHackers.MatterControl.DesignTools AddWebPageLinkIfRequired(context.item, mainContainer, theme); // add in an Update button if applicable - if (context.item.GetType().GetCustomAttributes(typeof(ShowUpdateButtonAttribute), true).FirstOrDefault() is ShowUpdateButtonAttribute showUpdate) + var showUpdate = context.item.GetType().GetCustomAttributes(typeof(ShowUpdateButtonAttribute), true).FirstOrDefault() as ShowUpdateButtonAttribute; + if (showUpdate?.Show == true) { var updateButton = new TextButton("Update".Localize(), theme) { diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs index b8b264048..e10af18a0 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs @@ -44,7 +44,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.PartPreviewWindow.View3D { - [ShowUpdateButton(false)] + [ShowUpdateButton] public class CombineObject3D_2 : OperationSourceContainerObject3D, IPropertyGridModifier, IBuildsOnThread { private CancellationTokenSource cancellationToken; diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/IntersectionObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/IntersectionObject3D_2.cs index 24fa8bad2..5c0e3f2ea 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/IntersectionObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/IntersectionObject3D_2.cs @@ -42,7 +42,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.PartPreviewWindow.View3D { - [ShowUpdateButton(false)] + [ShowUpdateButton] public class IntersectionObject3D_2 : OperationSourceContainerObject3D, IPropertyGridModifier { public IntersectionObject3D_2() diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D.cs index 57ebc46ee..4c1ee578d 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D.cs @@ -49,7 +49,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.PartPreviewWindow.View3D { [Obsolete("Use SubtractAndReplaceObject3D_2 instead", false)] - [ShowUpdateButton(true)] + [ShowUpdateButton(SuppressPropertyChangeUpdates = true)] public class SubtractAndReplaceObject3D : MeshWrapperObject3D, ISelectableChildContainer { public SubtractAndReplaceObject3D() diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D_2.cs index bde7577b9..49451015e 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D_2.cs @@ -45,7 +45,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.PartPreviewWindow.View3D { - [ShowUpdateButton(false)] + [ShowUpdateButton] public class SubtractAndReplaceObject3D_2 : OperationSourceContainerObject3D, ISelectableChildContainer, ICustomEditorDraw, IPropertyGridModifier { public SubtractAndReplaceObject3D_2() diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D.cs index f49eb232d..6b95c7935 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D.cs @@ -47,7 +47,7 @@ using MatterHackers.PolygonMesh.Csg; namespace MatterHackers.MatterControl.PartPreviewWindow.View3D { [Obsolete("Use SubtractObject3D_2 instead", false)] - [ShowUpdateButton(true)] + [ShowUpdateButton(SuppressPropertyChangeUpdates = true)] public class SubtractObject3D : MeshWrapperObject3D, ISelectableChildContainer { public SubtractObject3D() diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs index 22135eb91..01b7aab02 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs @@ -44,7 +44,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.PartPreviewWindow.View3D { - [ShowUpdateButton(false)] + [ShowUpdateButton] public class SubtractObject3D_2 : OperationSourceContainerObject3D, ISelectableChildContainer, ICustomEditorDraw, IPropertyGridModifier, IBuildsOnThread { public SubtractObject3D_2() diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 9578a32e7..d318d70f3 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 9578a32e7032236c2ff7fc1a588c6d099eec333d +Subproject commit d318d70f3f2772d1b987a63291a1860c7dfc04f9 From 98392156039405abfc6fb0032600f232a68ce71c Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Thu, 28 Apr 2022 14:08:30 -0700 Subject: [PATCH 4/4] Combine can subtract holes --- .../ApplicationView/SceneOperations.cs | 32 +++-------------- .../DesignTools/Operations/GroupObject3D.cs | 35 ++++++++++++++++++- .../Primitives/ComponentObject3D.cs | 2 +- .../View3D/Actions/SubtractObject3D_2.cs | 2 +- StaticData/Translations/Master.txt | 3 ++ 5 files changed, 43 insertions(+), 31 deletions(-) diff --git a/MatterControlLib/ApplicationView/SceneOperations.cs b/MatterControlLib/ApplicationView/SceneOperations.cs index 1f614bad3..6f02c4b5e 100644 --- a/MatterControlLib/ApplicationView/SceneOperations.cs +++ b/MatterControlLib/ApplicationView/SceneOperations.cs @@ -1073,37 +1073,12 @@ namespace MatterHackers.MatterControl return new SceneOperation("Group") { OperationType = typeof(SelectionGroupObject3D), - ResultType = typeof(GroupObject3D), + ResultType = typeof(GroupHolesAppliedObject3D), TitleGetter = () => "Group".Localize(), Action = (sceneContext) => { - var scene = sceneContext.Scene; - var selectedItem = scene.SelectedItem; - scene.SelectedItem = null; - - var newGroup = new GroupObject3D(); - // When grouping items, move them to be centered on their bounding box - newGroup.Children.Modify((gChildren) => - { - selectedItem.Clone().Children.Modify((sChildren) => - { - var center = selectedItem.GetAxisAlignedBoundingBox().Center; - - foreach (var child in sChildren) - { - child.Translate(-center.X, -center.Y, 0); - gChildren.Add(child); - } - - newGroup.Translate(center.X, center.Y, 0); - }); - }); - - scene.UndoBuffer.AddAndDo(new ReplaceCommand(selectedItem.Children.ToList(), new[] { newGroup })); - - newGroup.MakeNameNonColliding(); - - scene.SelectedItem = newGroup; + var group = new GroupHolesAppliedObject3D(); + group.WrapSelectedItemAndSelect(sceneContext.Scene); }, HelpTextGetter = () => "At least 2 parts must be selected".Localize().Stars(), IsEnabled = (sceneContext) => sceneContext.Scene is InteractiveScene scene @@ -1534,6 +1509,7 @@ namespace MatterHackers.MatterControl if (selectedItem != null) { return selectedItem is GroupObject3D + || selectedItem is GroupHolesAppliedObject3D || selectedItem.GetType() == typeof(Object3D) || selectedItem.CanApply; } diff --git a/MatterControlLib/DesignTools/Operations/GroupObject3D.cs b/MatterControlLib/DesignTools/Operations/GroupObject3D.cs index d2a875e0f..690f014e4 100644 --- a/MatterControlLib/DesignTools/Operations/GroupObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/GroupObject3D.cs @@ -29,10 +29,14 @@ either expressed or implied, of the FreeBSD Project. using MatterHackers.DataConverters3D; using MatterHackers.Localizations; +using MatterHackers.MatterControl.PartPreviewWindow.View3D; +using System; +using System.Linq; +using System.Text.Json.Serialization; namespace MatterHackers.MatterControl.DesignTools.Operations { - public class GroupObject3D : Object3D + public class GroupObject3D : Object3D { public override bool CanApply => true; @@ -41,4 +45,33 @@ namespace MatterHackers.MatterControl.DesignTools.Operations Name = "Group".Localize(); } } + + [ShowUpdateButton(Show = false)] + public class GroupHolesAppliedObject3D : SubtractObject3D_2 + { + public GroupHolesAppliedObject3D() + { + Name = "Group".Localize(); + } + + public override SelectedChildren SelectedChildren + { + get + { + var selections = new SelectedChildren(); + + foreach(var child in SourceContainer.DescendantsAndSelfMultipleChildrenFirstOrSelf().Children.Where(i => i.WorldOutputType(this) == PrintOutputTypes.Hole)) + { + selections.Add(child.ID); + } + + return selections; + } + + set + { + + } + } + } } \ No newline at end of file diff --git a/MatterControlLib/DesignTools/Primitives/ComponentObject3D.cs b/MatterControlLib/DesignTools/Primitives/ComponentObject3D.cs index b7362bed1..39f91107e 100644 --- a/MatterControlLib/DesignTools/Primitives/ComponentObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/ComponentObject3D.cs @@ -110,7 +110,7 @@ namespace MatterHackers.MatterControl.DesignTools if (newChildren.Count > 1) { - var group = new GroupObject3D + var group = new GroupHolesAppliedObject3D { Name = this.Name }; diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs index 01b7aab02..b55df7c58 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs @@ -54,7 +54,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } [DisplayName("Part(s) to Subtract")] - public SelectedChildren SelectedChildren { get; set; } = new SelectedChildren(); + public virtual SelectedChildren SelectedChildren { get; set; } = new SelectedChildren(); #if DEBUG public ProcessingModes Processing { get; set; } = ProcessingModes.Polygons; diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 11b153341..ad48a10c9 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -4339,6 +4339,9 @@ Translated:Select this option only if your printer does not appear in the list English:Select What to Import Translated:Select What to Import +English:Selected Children +Translated:Selected Children + English:Selected Material and Bed Surface are Incompatable Translated:Selected Material and Bed Surface are Incompatable