Merge pull request #5403 from larsbrubaker/main

better rebuilding for images and sheets
This commit is contained in:
Lars Brubaker 2022-11-25 17:03:47 -08:00 committed by GitHub
commit 0d5145368d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 66 additions and 45 deletions

View file

@ -348,16 +348,7 @@ namespace MatterHackers.MatterControl.DesignTools
Histogram.RangeEnd = .9;
}
if (AnalysisType != AnalysisTypes.Transparency)
{
Histogram.BuildHistogramFromImage(SourceImage, AnalysisType);
var _ = Image; // call this to make sure it is built
Histogram.RebuildAlphaImage(SourceImage, alphaImage, Image, AnalysisType);
}
else
{
Image?.CopyFrom(SourceImage);
}
CopyNewImageData();
await Rebuild();
this.ReloadEditorPannel();
@ -368,12 +359,27 @@ namespace MatterHackers.MatterControl.DesignTools
}
else if (SheetObject3D.NeedsRebuild(this, invalidateArgs))
{
await Rebuild();
CopyNewImageData();
await Rebuild();
}
base.OnInvalidate(invalidateArgs);
}
private void CopyNewImageData()
{
if (AnalysisType != AnalysisTypes.Transparency)
{
Histogram.BuildHistogramFromImage(SourceImage, AnalysisType);
var _ = Image; // call this to make sure it is built
Histogram.RebuildAlphaImage(SourceImage, alphaImage, Image, AnalysisType);
}
else
{
Image?.CopyFrom(SourceImage);
}
}
public override Task Rebuild()
{
this.DebugDepth("Rebuild");

View file

@ -32,6 +32,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
using CsvHelper;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
@ -107,23 +108,27 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
Name = "Linear Extrude".Localize();
}
public override async void OnInvalidate(InvalidateArgs eventArgs)
public override async void OnInvalidate(InvalidateArgs invalidateArgs)
{
if ((eventArgs.InvalidateType.HasFlag(InvalidateType.Path)
|| eventArgs.InvalidateType.HasFlag(InvalidateType.Children))
&& eventArgs.Source != this
if ((invalidateArgs.InvalidateType.HasFlag(InvalidateType.Path)
|| invalidateArgs.InvalidateType.HasFlag(InvalidateType.Children))
&& invalidateArgs.Source != this
&& !RebuildLocked)
{
await Rebuild();
}
else if (eventArgs.InvalidateType.HasFlag(InvalidateType.Properties)
&& eventArgs.Source == this)
else if (invalidateArgs.InvalidateType.HasFlag(InvalidateType.Properties)
&& invalidateArgs.Source == this)
{
await Rebuild();
}
else
{
base.OnInvalidate(eventArgs);
else if (SheetObject3D.NeedsRebuild(this, invalidateArgs))
{
await Rebuild();
}
else
{
base.OnInvalidate(invalidateArgs);
}
}

View file

@ -100,23 +100,23 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
Name = "Revolve".Localize();
}
public override async void OnInvalidate(InvalidateArgs eventArgs)
public override async void OnInvalidate(InvalidateArgs invalidateArgs)
{
if ((eventArgs.InvalidateType.HasFlag(InvalidateType.Path)
|| eventArgs.InvalidateType.HasFlag(InvalidateType.Children))
&& eventArgs.Source != this
if ((invalidateArgs.InvalidateType.HasFlag(InvalidateType.Path)
|| invalidateArgs.InvalidateType.HasFlag(InvalidateType.Children))
&& invalidateArgs.Source != this
&& !RebuildLocked)
{
await Rebuild();
}
else if (eventArgs.InvalidateType.HasFlag(InvalidateType.Properties)
&& eventArgs.Source == this)
else if (invalidateArgs.InvalidateType.HasFlag(InvalidateType.Properties)
&& invalidateArgs.Source == this)
{
await Rebuild();
}
else
{
base.OnInvalidate(eventArgs);
base.OnInvalidate(invalidateArgs);
}
}

View file

@ -66,22 +66,27 @@ namespace MatterHackers.MatterControl.DesignTools
var cell = this[cellId];
var expression = cell.Expression;
if (expression.StartsWith("="))
if (cell != null)
{
expression = expression.Substring(1);
var evaluator = new Expression(expression.ToLower());
AddConstants(evaluator);
var value = evaluator.calculate();
var expression = cell.Expression;
return value.ToString();
}
else
{
// return the expression without evaluation
return expression;
if (expression.StartsWith("="))
{
expression = expression.Substring(1);
var evaluator = new Expression(expression.ToLower());
AddConstants(evaluator);
var value = evaluator.calculate();
return value.ToString();
}
else
{
// return the expression without evaluation
return expression;
}
}
return "0";
}
}

View file

@ -519,9 +519,14 @@ namespace MatterHackers.MatterControl.DesignTools
}
}
return (T)(object)0;
}
}
if (typeof(T) == typeof(double))
{
return (T)(object)0;
}
return (T)(object)(int)0;
}
}
/// <summary>
/// Find the sheet that the given item will reference

@ -1 +1 @@
Subproject commit e437d4463e3bd565ea7c1fb6dbc6c5c1348c802c
Subproject commit 6f3ef82f9cad3ba1f1419c427336de60fbf6070e

@ -1 +1 @@
Subproject commit 1f0ad588760ac4629fd8f7844ec985087173b037
Subproject commit bf1743f908241e19886562ba9752944763417896