diff --git a/MatterControl.MeshOperations/OperationSourceContainerObject3D.cs b/MatterControl.MeshOperations/OperationSourceContainerObject3D.cs index 14783a8d5..02647ad44 100644 --- a/MatterControl.MeshOperations/OperationSourceContainerObject3D.cs +++ b/MatterControl.MeshOperations/OperationSourceContainerObject3D.cs @@ -192,8 +192,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations { await Rebuild(); } - else if (invalidateType.InvalidateType.HasFlag(InvalidateType.Properties) - && invalidateType.Source == this) + else if ((invalidateType.InvalidateType.HasFlag(InvalidateType.Properties) && invalidateType.Source == this) + || invalidateType.InvalidateType.HasFlag(InvalidateType.SheetUpdated)) { await Rebuild(); } diff --git a/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs b/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs index f0cd5dc9d..b8c4d54f9 100644 --- a/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs +++ b/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs @@ -109,51 +109,81 @@ namespace MatterHackers.MatterControl.DesignTools } } + internal class UpdateItem + { + internal int depth; + internal IObject3D item; + internal DataConverters3D.RebuildLock rubuildLock; + } private void SendInvalidateToAll() { - var updatedItems = new HashSet(); - updatedItems.Add(this); + var updateItems = new List(); foreach (var sibling in this.Parent.Children) { - SendInvalidateRecursive(sibling, updatedItems); - } - } - - private void SendInvalidateRecursive(IObject3D item, HashSet updatedItems) - { - if (updatedItems.Contains(item)) - { - return; + if (sibling != this) + { + AddItemsToList(sibling, updateItems, 0); + } } - // process depth first - foreach(var child in item.Children) + // sort them + updateItems.Sort((a, b) => a.depth.CompareTo(b.depth)); + // lock everything + foreach (var depthItem in updateItems) { - SendInvalidateRecursive(child, updatedItems); + depthItem.rubuildLock = depthItem.item.RebuildLock(); } // and send the invalidate RunningInterval runningInterval = null; void RebuildWhenUnlocked() { - if (!item.RebuildLocked) + // get the last item from the list + var index = updateItems.Count - 1; + var updateItem = updateItems[index]; + // if it is locked from above + if (updateItem.rubuildLock != null) + { + // release the lock and rebuild + updateItem.rubuildLock.Dispose(); + updateItem.rubuildLock = null; + // and ask it to update + updateItem.item.Invalidate(new InvalidateArgs(updateItem.item, InvalidateType.SheetUpdated)); + } + else if (updateItem.item.RebuildLocked) + { + // wait for the current rebuild to end + return; + } + else + { + // remove it from the list + updateItems.RemoveAt(index); + } + + if (updateItems.Count == 0) { - updatedItems.Add(item); UiThread.ClearInterval(runningInterval); - item.Invalidate(new InvalidateArgs(item, InvalidateType.SheetUpdated)); } } - if (!item.RebuildLocked) + // rebuild depth first + runningInterval = UiThread.SetInterval(RebuildWhenUnlocked, .01); + } + + private void AddItemsToList(IObject3D inItem, List updatedItems, int inDepth) + { + // process depth first + foreach(var child in inItem.Children) { - updatedItems.Add(item); - item.Invalidate(new InvalidateArgs(item, InvalidateType.SheetUpdated)); + AddItemsToList(child, updatedItems, inDepth + 1); } - else + + updatedItems.Add(new UpdateItem() { - // we need to get back to the user requested change when not locked - runningInterval = UiThread.SetInterval(RebuildWhenUnlocked, .2); - } + depth = inDepth, + item = inItem + }); } public static T EvaluateExpression(IObject3D owner, string inputExpression) diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs index f940a2b78..26716a23b 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs @@ -36,7 +36,6 @@ using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; using MatterHackers.MatterControl.DesignTools.Operations; -using MatterHackers.PolygonMesh; using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.PartPreviewWindow.View3D diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs index 1ac5f10b5..66d5c6193 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs @@ -105,8 +105,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D { await Rebuild(); } - else if (invalidateType.InvalidateType.HasFlag(InvalidateType.Properties) - && invalidateType.Source == this) + else if ((invalidateType.InvalidateType.HasFlag(InvalidateType.Properties) && invalidateType.Source == this) + || invalidateType.InvalidateType.HasFlag(InvalidateType.SheetUpdated)) { await Rebuild(); } diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index c0a371ba0..4f2487263 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit c0a371ba054c320109b0310fb8d71c169e52a337 +Subproject commit 4f2487263fef74b3c73937bc7c1faaa4523131ef diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index a6ead8c6f..0b4c79769 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit a6ead8c6fed2ff17bd0fb261d2212dcacb44664d +Subproject commit 0b4c79769aa23a62df17f10ec771c0bb95cdb352