integrating offline changes
This commit is contained in:
parent
121623bad3
commit
3f8eeda65b
125 changed files with 5442 additions and 5434 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2018, Lars Brubaker, John Lewin
|
||||
Copyright (c) 2023, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -32,94 +32,94 @@ using MatterHackers.DataConverters3D;
|
|||
|
||||
namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||
{
|
||||
public abstract class ArrayObject3D : OperationSourceContainerObject3D
|
||||
{
|
||||
public abstract IntOrExpression Count { get; set; }
|
||||
public abstract class ArrayObject3D : OperationSourceContainerObject3D
|
||||
{
|
||||
public abstract IntOrExpression Count { get; set; }
|
||||
|
||||
public override void Apply(Agg.UI.UndoBuffer undoBuffer)
|
||||
{
|
||||
var indexExpansions = new (string key, int index)[]
|
||||
{
|
||||
("[index]", 0),
|
||||
("[index0]", 0),
|
||||
("[index1]", 1),
|
||||
("[index2]", 2),
|
||||
};
|
||||
var indexExpansions = new (string key, int index)[]
|
||||
{
|
||||
("[index]", 0),
|
||||
("[index0]", 0),
|
||||
("[index1]", 1),
|
||||
("[index2]", 2),
|
||||
};
|
||||
|
||||
// convert [index] expressions to their constant values
|
||||
foreach (var item in this.Descendants((item) => !(item is ArrayObject3D)))
|
||||
{
|
||||
foreach (var expansion in indexExpansions)
|
||||
{
|
||||
foreach (var expression in SheetObject3D.GetActiveExpressions(item, expansion.key, false))
|
||||
{
|
||||
var expressionValue = expression.Expression;
|
||||
expression.Expression = expressionValue.Replace(expansion.key, SheetObject3D.RetrieveArrayIndex(item, expansion.index).ToString());
|
||||
}
|
||||
// convert [index] expressions to their constant values
|
||||
foreach (var item in this.Descendants((item) => !(item is ArrayObject3D)))
|
||||
{
|
||||
foreach (var expansion in indexExpansions)
|
||||
{
|
||||
foreach (var expression in Expressions.GetActiveExpression(item, expansion.key, false))
|
||||
{
|
||||
var expressionValue = expression.Expression;
|
||||
expression.Expression = expressionValue.Replace(expansion.key, Expressions.RetrieveArrayIndex(item, expansion.index).ToString());
|
||||
}
|
||||
|
||||
// Also convert index expressions in ComponentObjects to their constants
|
||||
if (item is ComponentObject3D component)
|
||||
{
|
||||
for (int i = 0; i < component.SurfacedEditors.Count; i++)
|
||||
{
|
||||
var (cellId, cellData) = component.DecodeContent(i);
|
||||
// Also convert index expressions in ComponentObjects to their constants
|
||||
if (item is ComponentObject3D component)
|
||||
{
|
||||
for (int i = 0; i < component.SurfacedEditors.Count; i++)
|
||||
{
|
||||
var (cellId, cellData) = component.DecodeContent(i);
|
||||
|
||||
if (cellId != null)
|
||||
{
|
||||
var newValue = cellData.Replace(expansion.key, SheetObject3D.RetrieveArrayIndex(component, expansion.index).ToString());
|
||||
component.SurfacedEditors[i] = "!" + cellId + "," + newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cellId != null)
|
||||
{
|
||||
var newValue = cellData.Replace(expansion.key, Expressions.RetrieveArrayIndex(component, expansion.index).ToString());
|
||||
component.SurfacedEditors[i] = "!" + cellId + "," + newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// then call base apply
|
||||
base.Apply(undoBuffer);
|
||||
// then call base apply
|
||||
base.Apply(undoBuffer);
|
||||
}
|
||||
|
||||
internal void ProcessIndexExpressions()
|
||||
{
|
||||
var updateItems = SheetObject3D.SortAndLockUpdateItems(this, (item) =>
|
||||
{
|
||||
if (!SheetObject3D.HasExpressionWithString(item, "=", true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// WIP
|
||||
if (item.Parent == this)
|
||||
{
|
||||
// only process our children that are not the source object
|
||||
return !(item is OperationSourceObject3D);
|
||||
}
|
||||
else if (item.Parent is OperationSourceContainerObject3D)
|
||||
{
|
||||
// If we find another source container
|
||||
// Only process its children that are the source container (they will be replicated and modified correctly by the source container)
|
||||
return item is OperationSourceObject3D;
|
||||
}
|
||||
else if (item.Parent is OperationSourceObject3D operationSourceObject3D
|
||||
&& operationSourceObject3D.Parent == this)
|
||||
{
|
||||
// we don't need to rebuild our source object
|
||||
return false;
|
||||
}
|
||||
else if (item.Parent is ComponentObject3D)
|
||||
var updateItems = Expressions.SortAndLockUpdateItems(this, (item) =>
|
||||
{
|
||||
if (!Expressions.HasExpressionWithString(item, "=", true))
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// process everything else
|
||||
return true;
|
||||
}, true);
|
||||
// WIP
|
||||
if (item.Parent == this)
|
||||
{
|
||||
// only process our children that are not the source object
|
||||
return !(item is OperationSourceObject3D);
|
||||
}
|
||||
else if (item.Parent is OperationSourceContainerObject3D)
|
||||
{
|
||||
// If we find another source container
|
||||
// Only process its children that are the source container (they will be replicated and modified correctly by the source container)
|
||||
return item is OperationSourceObject3D;
|
||||
}
|
||||
else if (item.Parent is OperationSourceObject3D operationSourceObject3D
|
||||
&& operationSourceObject3D.Parent == this)
|
||||
{
|
||||
// we don't need to rebuild our source object
|
||||
return false;
|
||||
}
|
||||
else if (item.Parent is ComponentObject3D)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var runningInterval = SheetObject3D.SendInvalidateInRebuildOrder(updateItems, InvalidateType.Properties);
|
||||
// process everything else
|
||||
return true;
|
||||
}, true);
|
||||
|
||||
while (runningInterval.Active)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
var runningInterval = Expressions.SendInvalidateInRebuildOrder(updateItems, InvalidateType.Properties);
|
||||
|
||||
while (runningInterval.Active)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue