Merge pull request #5403 from larsbrubaker/main
better rebuilding for images and sheets
This commit is contained in:
commit
0d5145368d
7 changed files with 66 additions and 45 deletions
|
|
@ -348,16 +348,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
Histogram.RangeEnd = .9;
|
Histogram.RangeEnd = .9;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AnalysisType != AnalysisTypes.Transparency)
|
CopyNewImageData();
|
||||||
{
|
|
||||||
Histogram.BuildHistogramFromImage(SourceImage, AnalysisType);
|
|
||||||
var _ = Image; // call this to make sure it is built
|
|
||||||
Histogram.RebuildAlphaImage(SourceImage, alphaImage, Image, AnalysisType);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Image?.CopyFrom(SourceImage);
|
|
||||||
}
|
|
||||||
await Rebuild();
|
await Rebuild();
|
||||||
|
|
||||||
this.ReloadEditorPannel();
|
this.ReloadEditorPannel();
|
||||||
|
|
@ -368,12 +359,27 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
else if (SheetObject3D.NeedsRebuild(this, invalidateArgs))
|
else if (SheetObject3D.NeedsRebuild(this, invalidateArgs))
|
||||||
{
|
{
|
||||||
await Rebuild();
|
CopyNewImageData();
|
||||||
|
await Rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnInvalidate(invalidateArgs);
|
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()
|
public override Task Rebuild()
|
||||||
{
|
{
|
||||||
this.DebugDepth("Rebuild");
|
this.DebugDepth("Rebuild");
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using CsvHelper;
|
||||||
using MatterHackers.Agg.UI;
|
using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.Agg.VertexSource;
|
using MatterHackers.Agg.VertexSource;
|
||||||
using MatterHackers.DataConverters3D;
|
using MatterHackers.DataConverters3D;
|
||||||
|
|
@ -107,23 +108,27 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
Name = "Linear Extrude".Localize();
|
Name = "Linear Extrude".Localize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async void OnInvalidate(InvalidateArgs eventArgs)
|
public override async void OnInvalidate(InvalidateArgs invalidateArgs)
|
||||||
{
|
{
|
||||||
if ((eventArgs.InvalidateType.HasFlag(InvalidateType.Path)
|
if ((invalidateArgs.InvalidateType.HasFlag(InvalidateType.Path)
|
||||||
|| eventArgs.InvalidateType.HasFlag(InvalidateType.Children))
|
|| invalidateArgs.InvalidateType.HasFlag(InvalidateType.Children))
|
||||||
&& eventArgs.Source != this
|
&& invalidateArgs.Source != this
|
||||||
&& !RebuildLocked)
|
&& !RebuildLocked)
|
||||||
{
|
{
|
||||||
await Rebuild();
|
await Rebuild();
|
||||||
}
|
}
|
||||||
else if (eventArgs.InvalidateType.HasFlag(InvalidateType.Properties)
|
else if (invalidateArgs.InvalidateType.HasFlag(InvalidateType.Properties)
|
||||||
&& eventArgs.Source == this)
|
&& invalidateArgs.Source == this)
|
||||||
{
|
{
|
||||||
await Rebuild();
|
await Rebuild();
|
||||||
}
|
}
|
||||||
else
|
else if (SheetObject3D.NeedsRebuild(this, invalidateArgs))
|
||||||
{
|
{
|
||||||
base.OnInvalidate(eventArgs);
|
await Rebuild();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base.OnInvalidate(invalidateArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,23 +100,23 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
Name = "Revolve".Localize();
|
Name = "Revolve".Localize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async void OnInvalidate(InvalidateArgs eventArgs)
|
public override async void OnInvalidate(InvalidateArgs invalidateArgs)
|
||||||
{
|
{
|
||||||
if ((eventArgs.InvalidateType.HasFlag(InvalidateType.Path)
|
if ((invalidateArgs.InvalidateType.HasFlag(InvalidateType.Path)
|
||||||
|| eventArgs.InvalidateType.HasFlag(InvalidateType.Children))
|
|| invalidateArgs.InvalidateType.HasFlag(InvalidateType.Children))
|
||||||
&& eventArgs.Source != this
|
&& invalidateArgs.Source != this
|
||||||
&& !RebuildLocked)
|
&& !RebuildLocked)
|
||||||
{
|
{
|
||||||
await Rebuild();
|
await Rebuild();
|
||||||
}
|
}
|
||||||
else if (eventArgs.InvalidateType.HasFlag(InvalidateType.Properties)
|
else if (invalidateArgs.InvalidateType.HasFlag(InvalidateType.Properties)
|
||||||
&& eventArgs.Source == this)
|
&& invalidateArgs.Source == this)
|
||||||
{
|
{
|
||||||
await Rebuild();
|
await Rebuild();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
base.OnInvalidate(eventArgs);
|
base.OnInvalidate(invalidateArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,22 +66,27 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
var cell = this[cellId];
|
var cell = this[cellId];
|
||||||
|
|
||||||
var expression = cell.Expression;
|
if (cell != null)
|
||||||
|
|
||||||
if (expression.StartsWith("="))
|
|
||||||
{
|
{
|
||||||
expression = expression.Substring(1);
|
var expression = cell.Expression;
|
||||||
var evaluator = new Expression(expression.ToLower());
|
|
||||||
AddConstants(evaluator);
|
|
||||||
var value = evaluator.calculate();
|
|
||||||
|
|
||||||
return value.ToString();
|
if (expression.StartsWith("="))
|
||||||
}
|
{
|
||||||
else
|
expression = expression.Substring(1);
|
||||||
{
|
var evaluator = new Expression(expression.ToLower());
|
||||||
// return the expression without evaluation
|
AddConstants(evaluator);
|
||||||
return expression;
|
var value = evaluator.calculate();
|
||||||
|
|
||||||
|
return value.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// return the expression without evaluation
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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>
|
/// <summary>
|
||||||
/// Find the sheet that the given item will reference
|
/// 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue