From 383fd7e5db98c289c80950f9930ab46a9bb97541 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 10 Aug 2018 14:34:24 -0700 Subject: [PATCH 1/2] Made component able to be applied and removed issue: MatterHackers/MCCentral#3951 Get apply button working for Image Converter --- DesignTools/Primitives/ComponentObject3D.cs | 55 +++++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/DesignTools/Primitives/ComponentObject3D.cs b/DesignTools/Primitives/ComponentObject3D.cs index 576932e3a..e477f15cf 100644 --- a/DesignTools/Primitives/ComponentObject3D.cs +++ b/DesignTools/Primitives/ComponentObject3D.cs @@ -27,25 +27,72 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -using System.Collections.Generic; +using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; +using MatterHackers.DataConverters3D.UndoCommands; using MatterHackers.MatterControl.CustomWidgets; +using MatterHackers.MatterControl.DesignTools.Operations; +using System.Collections.Generic; +using MatterHackers.Localizations; namespace MatterHackers.MatterControl.DesignTools { public class ComponentObject3D : Object3D, IVisualLeafNode { - public bool Finalized { get; set; } = true; - public ComponentObject3D() { } public ComponentObject3D(IEnumerable children) - : base (children) + : base(children) { } + public override bool CanApply => Finalized; + public bool Finalized { get; set; } = true; public List SurfacedEditors { get; set; } = new List(); + + public override void Apply(UndoBuffer undoBuffer) + { + // we want to end up with just a group of all the visible mesh objects + using (RebuildLock()) + { + List newChildren = new List(); + + // push our matrix into a copy of our visible children + foreach (var child in this.VisibleMeshes()) + { + var meshOnlyItem = new Object3D(); + meshOnlyItem.Matrix = child.WorldMatrix(this); + meshOnlyItem.Color = child.WorldColor(this); + meshOnlyItem.MaterialIndex = child.WorldMaterialIndex(this); + meshOnlyItem.OutputType = child.WorldOutputType(this); + meshOnlyItem.Mesh = child.Mesh; + meshOnlyItem.Name = "Mesh".Localize(); + newChildren.Add(meshOnlyItem); + } + + if(newChildren.Count > 1) + { + var group = new GroupObject3D(); + group.Name = this.Name; + group.Children.Modify(list => + { + list.AddRange(newChildren); + }); + newChildren.Clear(); + newChildren.Add(group); + } + else if(newChildren.Count == 1) + { + newChildren[0].Name = this.Name; + } + + // and replace us with the children + undoBuffer.AddAndDo(new ReplaceCommand(new List { this }, newChildren)); + } + + Invalidate(new InvalidateArgs(this, InvalidateType.Content, undoBuffer)); + } } } \ No newline at end of file From 0bbcb2012f10b2f3bbda378a714645b5af0c88f1 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Fri, 10 Aug 2018 16:11:50 -0700 Subject: [PATCH 2/2] Add C5 NuGet to automation tests, add Dremel OemUrl --- StaticData/OEMSettings/OEMUrls.json | 1 + Submodules/agg-sharp | 2 +- .../MatterControl.AutomationTests.csproj | 3 +++ Tests/MatterControl.AutomationTests/packages.config | 1 + Tests/MatterControl.Tests/MatterControl.Tests.csproj | 3 +++ Tests/MatterControl.Tests/packages.config | 1 + 6 files changed, 10 insertions(+), 1 deletion(-) diff --git a/StaticData/OEMSettings/OEMUrls.json b/StaticData/OEMSettings/OEMUrls.json index edf85b9ac..01406c7bd 100644 --- a/StaticData/OEMSettings/OEMUrls.json +++ b/StaticData/OEMSettings/OEMUrls.json @@ -6,6 +6,7 @@ "BeeVeryCreative": "https://beeverycreative.com/", "Blue Eagle Labs": "https://www.blueeaglelabs.com/", "Deezmaker": "http://deezmaker.com/", + "Dremel": "http://www.dremel.com/", "FlashForge": "http://www.flashforge.com/", "gCreate": "http://www.gcreate.com/", "IRA3D": "", diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 0aa034ed8..be8e29dd6 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 0aa034ed886a837411ffc45ac7dd5eb0abf051ac +Subproject commit be8e29dd6bbfd8fe6f2c2064171211c9cbf0c067 diff --git a/Tests/MatterControl.AutomationTests/MatterControl.AutomationTests.csproj b/Tests/MatterControl.AutomationTests/MatterControl.AutomationTests.csproj index cb2e0d5b1..55e48c389 100644 --- a/Tests/MatterControl.AutomationTests/MatterControl.AutomationTests.csproj +++ b/Tests/MatterControl.AutomationTests/MatterControl.AutomationTests.csproj @@ -33,6 +33,9 @@ AnyCPU + + ..\..\packages\C5.2.5.3\lib\net45\C5.dll + ..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True diff --git a/Tests/MatterControl.AutomationTests/packages.config b/Tests/MatterControl.AutomationTests/packages.config index 5e624b84e..7c82fba69 100644 --- a/Tests/MatterControl.AutomationTests/packages.config +++ b/Tests/MatterControl.AutomationTests/packages.config @@ -1,5 +1,6 @@  + diff --git a/Tests/MatterControl.Tests/MatterControl.Tests.csproj b/Tests/MatterControl.Tests/MatterControl.Tests.csproj index 2f1bd30c7..60a6431e2 100644 --- a/Tests/MatterControl.Tests/MatterControl.Tests.csproj +++ b/Tests/MatterControl.Tests/MatterControl.Tests.csproj @@ -37,6 +37,9 @@ AnyCPU + + ..\..\packages\C5.2.5.3\lib\net45\C5.dll + ..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True diff --git a/Tests/MatterControl.Tests/packages.config b/Tests/MatterControl.Tests/packages.config index 8fa8777d9..e29b24805 100644 --- a/Tests/MatterControl.Tests/packages.config +++ b/Tests/MatterControl.Tests/packages.config @@ -1,5 +1,6 @@  +