diff --git a/MatterControlLib/ApplicationView/SceneOperations.cs b/MatterControlLib/ApplicationView/SceneOperations.cs index e97516c40..0627282fb 100644 --- a/MatterControlLib/ApplicationView/SceneOperations.cs +++ b/MatterControlLib/ApplicationView/SceneOperations.cs @@ -754,6 +754,9 @@ namespace MatterHackers.MatterControl ArrangeAllPartsOperation(), new SceneSelectionSeparator(), LayFlatOperation(), +#if DEBUG + RebuildOperation(), +#endif GroupOperation(), UngroupOperation(), new SceneSelectionSeparator(), @@ -1174,6 +1177,42 @@ namespace MatterHackers.MatterControl }; } + private static SceneOperation RebuildOperation() + { + return new SceneOperation("Rebuild") + { + TitleGetter = () => "Rebuild".Localize(), + Action = (sceneContext) => + { + var scene = sceneContext.Scene; + var selectedItem = scene.SelectedItem; + if (selectedItem != null) + { + try + { + var updateItems = SheetObject3D.SortAndLockUpdateItems(selectedItem.Parent, (item) => + { + if (item == selectedItem || item.Parent == selectedItem) + { + // don't process this + return false; + } + return true; + }, false); + + SheetObject3D.SendInvalidateInRebuildOrder(updateItems, InvalidateType.Properties, null); + } + catch + { + } + } + }, + HelpTextGetter = () => "At least 1 part must be selected".Localize().Stars(), + IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null, + Icon = (theme) => StaticData.Instance.LoadIcon("update.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply(), + }; + } + private static SceneOperation LinearArrayOperation() { return new SceneOperation("Linear Array") diff --git a/MatterControlLib/DesignTools/Operations/ArrayObject3D.cs b/MatterControlLib/DesignTools/Operations/ArrayObject3D.cs index 628e66fa0..3e807d75e 100644 --- a/MatterControlLib/DesignTools/Operations/ArrayObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/ArrayObject3D.cs @@ -111,7 +111,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations // process everything else return true; - }); + }, true); var runningInterval = SheetObject3D.SendInvalidateInRebuildOrder(updateItems, InvalidateType.Properties); diff --git a/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs b/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs index 56f94a184..d121ce648 100644 --- a/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs +++ b/MatterControlLib/DesignTools/Sheets/SheetObject3D.cs @@ -132,7 +132,7 @@ namespace MatterHackers.MatterControl.DesignTools } } - public static List SortAndLockUpdateItems(IObject3D root, Func includeObject) + public static List SortAndLockUpdateItems(IObject3D root, Func includeObject, bool checkForExpression) { var requiredUpdateItems = new Dictionary(); foreach (var child in root.Descendants()) @@ -146,8 +146,8 @@ namespace MatterHackers.MatterControl.DesignTools depthToThis++; parent = parent.Parent; } - - AddItemsRequiringUpdateToDictionary(child, requiredUpdateItems, depthToThis, includeObject); + + AddItemsRequiringUpdateToDictionary(child, requiredUpdateItems, depthToThis, includeObject, checkForExpression); } } @@ -181,13 +181,13 @@ namespace MatterHackers.MatterControl.DesignTools } return true; - }); + }, true); SendInvalidateInRebuildOrder(updateItems, InvalidateType.SheetUpdated, this); } public static RunningInterval SendInvalidateInRebuildOrder(List updateItems, - InvalidateType sheetUpdated, + InvalidateType invalidateType, IObject3D sender = null) { // and send the invalidate @@ -214,7 +214,7 @@ namespace MatterHackers.MatterControl.DesignTools updateItem.rebuildLock.Dispose(); updateItem.rebuildLock = null; var updateSender = sender == null ? updateItem.item : sender; - updateItem.item.Invalidate(new InvalidateArgs(updateSender, sheetUpdated)); + updateItem.item.Invalidate(new InvalidateArgs(updateSender, invalidateType)); } } } @@ -250,17 +250,21 @@ namespace MatterHackers.MatterControl.DesignTools return runningInterval; } - private static void AddItemsRequiringUpdateToDictionary(IObject3D inItem, Dictionary updatedItems, int inDepth, Func includeObject) + private static void AddItemsRequiringUpdateToDictionary(IObject3D inItem, + Dictionary updatedItems, + int inDepth, + Func includeObject, + bool checkForExpression) { // process depth first foreach(var child in inItem.Children) { - AddItemsRequiringUpdateToDictionary(child, updatedItems, inDepth + 1, includeObject); + AddItemsRequiringUpdateToDictionary(child, updatedItems, inDepth + 1, includeObject, checkForExpression); } var depth2 = inDepth; if (includeObject(inItem) - && HasExpressionWithString(inItem, "=", true)) + && (!checkForExpression || HasExpressionWithString(inItem, "=", true))) { var itemToAdd = inItem; while (itemToAdd != null diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 338231d1f..86dc328a5 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 338231d1f1bafe87d200435b065035846e75ca60 +Subproject commit 86dc328a559f0fe025d1ccb9cee42cc9e2951549