commit
4ee2a41852
8 changed files with 105 additions and 70 deletions
|
|
@ -99,7 +99,6 @@ namespace MatterHackers.PolygonMesh
|
|||
var matrix = SliceLayer.GetTransformTo0Plane(plane);
|
||||
transformTo0Planes[plane] = (matrix, matrix.Inverted);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Mesh Calculate(CsgModes operation,
|
||||
|
|
@ -118,6 +117,11 @@ namespace MatterHackers.PolygonMesh
|
|||
{
|
||||
var mesh1 = transformedMeshes[mesh1Index];
|
||||
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int faceIndex = 0; faceIndex < mesh1.Faces.Count; faceIndex++)
|
||||
{
|
||||
var face = mesh1.Faces[faceIndex];
|
||||
|
|
|
|||
|
|
@ -101,6 +101,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
lastChild = next;
|
||||
}
|
||||
});
|
||||
|
||||
ProcessIndexExpressions();
|
||||
|
||||
SourceContainer.Visible = false;
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -94,42 +94,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
list.AddRange(newChildren);
|
||||
});
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// process everything else
|
||||
return true;
|
||||
});
|
||||
|
||||
var runningInterval = SheetObject3D.SendInvalidateInRebuildOrder(updateItems, InvalidateType.Properties);
|
||||
|
||||
while (runningInterval.Active)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
ProcessIndexExpressions();
|
||||
|
||||
SourceContainer.Visible = false;
|
||||
rebuildLock.Dispose();
|
||||
|
|
|
|||
|
|
@ -27,19 +27,68 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.DesignTools.EditableTypes;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||
{
|
||||
public abstract class ArrayObject3D : OperationSourceContainerObject3D
|
||||
{
|
||||
public abstract IntOrExpression Count { get; set; }
|
||||
|
||||
public override void Flatten(Agg.UI.UndoBuffer undoBuffer)
|
||||
{
|
||||
// convert [index] expressions to their constant values
|
||||
foreach (var item in this.Descendants((item) => !(item is ArrayObject3D)))
|
||||
{
|
||||
foreach(var expression in SheetObject3D.GetActiveExpressions(item, "[index]", false))
|
||||
{
|
||||
expression.Expression = expression.Expression.Replace("[index]", SheetObject3D.RetrieveArrayIndex(item, 0).ToString());
|
||||
}
|
||||
}
|
||||
|
||||
// then call base flatten
|
||||
base.Flatten(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;
|
||||
}
|
||||
|
||||
// process everything else
|
||||
return true;
|
||||
});
|
||||
|
||||
var runningInterval = SheetObject3D.SendInvalidateInRebuildOrder(updateItems, InvalidateType.Properties);
|
||||
|
||||
while (runningInterval.Active)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -128,6 +128,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
list.Add(next);
|
||||
}
|
||||
});
|
||||
|
||||
ProcessIndexExpressions();
|
||||
|
||||
SourceContainer.Visible = false;
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -334,9 +334,9 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
return null;
|
||||
}
|
||||
|
||||
private static int RetrieveArrayIndex(IObject3D owner, int level)
|
||||
public static int RetrieveArrayIndex(IObject3D item, int level)
|
||||
{
|
||||
var arrayObject = FindParentArray(owner, level);
|
||||
var arrayObject = FindParentArray(item, level);
|
||||
|
||||
if (arrayObject != null)
|
||||
{
|
||||
|
|
@ -345,7 +345,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
if (!(child is OperationSourceObject3D))
|
||||
{
|
||||
if (child.DescendantsAndSelf().Where(i => i == owner).Any())
|
||||
if (child.DescendantsAndSelf().Where(i => i == item).Any())
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
|
@ -502,31 +502,42 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
return false;
|
||||
}
|
||||
|
||||
public static IEnumerable<IDirectOrExpression> GetActiveExpressions(IObject3D item, string checkForString, bool startsWith)
|
||||
{
|
||||
foreach (var property in PublicPropertyEditor.GetEditablePropreties(item))
|
||||
{
|
||||
var propertyValue = property.Value;
|
||||
|
||||
if (propertyValue is IDirectOrExpression directOrExpression)
|
||||
{
|
||||
if (startsWith)
|
||||
{
|
||||
if (directOrExpression.Expression.StartsWith(checkForString))
|
||||
{
|
||||
// WIP: check if the value has actually changed, this will update every object on any cell change
|
||||
yield return directOrExpression;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(directOrExpression.Expression.Contains(checkForString))
|
||||
{
|
||||
yield return directOrExpression;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool HasExpressionWithString(IObject3D itemToCheck, string checkForString, bool startsWith)
|
||||
{
|
||||
foreach (var item in itemToCheck.DescendantsAndSelf())
|
||||
{
|
||||
// Find all the OrReference properties on this item and check if any start with an '='.
|
||||
foreach (var property in PublicPropertyEditor.GetEditablePropreties(item))
|
||||
{
|
||||
var propertyValue = property.Value;
|
||||
|
||||
if (propertyValue is IDirectOrExpression directOrExpression)
|
||||
{
|
||||
if (startsWith)
|
||||
{
|
||||
if (directOrExpression.Expression.StartsWith(checkForString))
|
||||
{
|
||||
// WIP: check if the value has actually changed, this will update every object on any cell change
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return directOrExpression.Expression.Contains(checkForString);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (GetActiveExpressions(item, checkForString, startsWith).Any())
|
||||
{
|
||||
// three is one so return true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 939abf3577f5dc66a3a2d9eb02d3965dca7264f8
|
||||
Subproject commit ee639857de9d8157d9a656d3dc76c07aba02818b
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 66f77f1cd52f85b7ac3ac6b8e711ad01f32519c5
|
||||
Subproject commit 183673e004d7c085cb970bd5b8f04fbd3f4750b1
|
||||
Loading…
Add table
Add a link
Reference in a new issue