Working on a rebuild selection operation
This commit is contained in:
parent
f8153190fe
commit
c25ba86b68
4 changed files with 54 additions and 11 deletions
|
|
@ -754,6 +754,9 @@ namespace MatterHackers.MatterControl
|
||||||
ArrangeAllPartsOperation(),
|
ArrangeAllPartsOperation(),
|
||||||
new SceneSelectionSeparator(),
|
new SceneSelectionSeparator(),
|
||||||
LayFlatOperation(),
|
LayFlatOperation(),
|
||||||
|
#if DEBUG
|
||||||
|
RebuildOperation(),
|
||||||
|
#endif
|
||||||
GroupOperation(),
|
GroupOperation(),
|
||||||
UngroupOperation(),
|
UngroupOperation(),
|
||||||
new SceneSelectionSeparator(),
|
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()
|
private static SceneOperation LinearArrayOperation()
|
||||||
{
|
{
|
||||||
return new SceneOperation("Linear Array")
|
return new SceneOperation("Linear Array")
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
|
|
||||||
// process everything else
|
// process everything else
|
||||||
return true;
|
return true;
|
||||||
});
|
}, true);
|
||||||
|
|
||||||
var runningInterval = SheetObject3D.SendInvalidateInRebuildOrder(updateItems, InvalidateType.Properties);
|
var runningInterval = SheetObject3D.SendInvalidateInRebuildOrder(updateItems, InvalidateType.Properties);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<UpdateItem> SortAndLockUpdateItems(IObject3D root, Func<IObject3D, bool> includeObject)
|
public static List<UpdateItem> SortAndLockUpdateItems(IObject3D root, Func<IObject3D, bool> includeObject, bool checkForExpression)
|
||||||
{
|
{
|
||||||
var requiredUpdateItems = new Dictionary<IObject3D, UpdateItem>();
|
var requiredUpdateItems = new Dictionary<IObject3D, UpdateItem>();
|
||||||
foreach (var child in root.Descendants())
|
foreach (var child in root.Descendants())
|
||||||
|
|
@ -146,8 +146,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
depthToThis++;
|
depthToThis++;
|
||||||
parent = parent.Parent;
|
parent = parent.Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddItemsRequiringUpdateToDictionary(child, requiredUpdateItems, depthToThis, includeObject);
|
AddItemsRequiringUpdateToDictionary(child, requiredUpdateItems, depthToThis, includeObject, checkForExpression);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,13 +181,13 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
}, true);
|
||||||
|
|
||||||
SendInvalidateInRebuildOrder(updateItems, InvalidateType.SheetUpdated, this);
|
SendInvalidateInRebuildOrder(updateItems, InvalidateType.SheetUpdated, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RunningInterval SendInvalidateInRebuildOrder(List<UpdateItem> updateItems,
|
public static RunningInterval SendInvalidateInRebuildOrder(List<UpdateItem> updateItems,
|
||||||
InvalidateType sheetUpdated,
|
InvalidateType invalidateType,
|
||||||
IObject3D sender = null)
|
IObject3D sender = null)
|
||||||
{
|
{
|
||||||
// and send the invalidate
|
// and send the invalidate
|
||||||
|
|
@ -214,7 +214,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
updateItem.rebuildLock.Dispose();
|
updateItem.rebuildLock.Dispose();
|
||||||
updateItem.rebuildLock = null;
|
updateItem.rebuildLock = null;
|
||||||
var updateSender = sender == null ? updateItem.item : sender;
|
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;
|
return runningInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddItemsRequiringUpdateToDictionary(IObject3D inItem, Dictionary<IObject3D, UpdateItem> updatedItems, int inDepth, Func<IObject3D, bool> includeObject)
|
private static void AddItemsRequiringUpdateToDictionary(IObject3D inItem,
|
||||||
|
Dictionary<IObject3D, UpdateItem> updatedItems,
|
||||||
|
int inDepth,
|
||||||
|
Func<IObject3D, bool> includeObject,
|
||||||
|
bool checkForExpression)
|
||||||
{
|
{
|
||||||
// process depth first
|
// process depth first
|
||||||
foreach(var child in inItem.Children)
|
foreach(var child in inItem.Children)
|
||||||
{
|
{
|
||||||
AddItemsRequiringUpdateToDictionary(child, updatedItems, inDepth + 1, includeObject);
|
AddItemsRequiringUpdateToDictionary(child, updatedItems, inDepth + 1, includeObject, checkForExpression);
|
||||||
}
|
}
|
||||||
|
|
||||||
var depth2 = inDepth;
|
var depth2 = inDepth;
|
||||||
if (includeObject(inItem)
|
if (includeObject(inItem)
|
||||||
&& HasExpressionWithString(inItem, "=", true))
|
&& (!checkForExpression || HasExpressionWithString(inItem, "=", true)))
|
||||||
{
|
{
|
||||||
var itemToAdd = inItem;
|
var itemToAdd = inItem;
|
||||||
while (itemToAdd != null
|
while (itemToAdd != null
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 338231d1f1bafe87d200435b065035846e75ca60
|
Subproject commit 86dc328a559f0fe025d1ccb9cee42cc9e2951549
|
||||||
Loading…
Add table
Add a link
Reference in a new issue