Adding ability to cancel rebuilding
This commit is contained in:
parent
aa795f1d3b
commit
dd3912a504
86 changed files with 257 additions and 67 deletions
|
|
@ -2171,14 +2171,14 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
printer.ViewState.SlicingItem = true;
|
printer.ViewState.SlicingItem = true;
|
||||||
|
|
||||||
await this.Tasks.Execute("Slicing".Localize(), printer, async (reporter, cancellationToken) =>
|
await this.Tasks.Execute("Slicing".Localize(), printer, async (reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
slicingSucceeded = await Slicer.SliceItem(
|
slicingSucceeded = await Slicer.SliceItem(
|
||||||
object3D,
|
object3D,
|
||||||
gcodeFilePath,
|
gcodeFilePath,
|
||||||
printer,
|
printer,
|
||||||
reporter,
|
reporter,
|
||||||
cancellationToken);
|
cancellationTokenSource.Token);
|
||||||
});
|
});
|
||||||
|
|
||||||
printer.ViewState.SlicingItem = false;
|
printer.ViewState.SlicingItem = false;
|
||||||
|
|
@ -2217,13 +2217,13 @@ namespace MatterHackers.MatterControl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.Tasks.Execute("Loading GCode".Localize(), printer, (innerProgress, token) =>
|
await this.Tasks.Execute("Loading GCode".Localize(), printer, (innerProgress, concelationTokenSource) =>
|
||||||
{
|
{
|
||||||
var status = new ProgressStatus();
|
var status = new ProgressStatus();
|
||||||
|
|
||||||
innerProgress.Report(status);
|
innerProgress.Report(status);
|
||||||
|
|
||||||
printer.Bed.LoadActiveSceneGCode(gcodeFilePath, token, (progress0to1, statusText) =>
|
printer.Bed.LoadActiveSceneGCode(gcodeFilePath, concelationTokenSource.Token, (progress0to1, statusText) =>
|
||||||
{
|
{
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
|
|
@ -2434,7 +2434,7 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
public int Priority { get; set; }
|
public int Priority { get; set; }
|
||||||
|
|
||||||
public Func<IProgress<ProgressStatus>, CancellationToken, Task> Action { get; set; }
|
public Func<IProgress<ProgressStatus>, CancellationTokenSource, Task> Action { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StartupAction
|
public class StartupAction
|
||||||
|
|
|
||||||
|
|
@ -159,12 +159,12 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
public async Task LoadGCodeContent(Stream stream)
|
public async Task LoadGCodeContent(Stream stream)
|
||||||
{
|
{
|
||||||
await ApplicationController.Instance.Tasks.Execute("Loading G-Code".Localize(), Printer, (reporter, cancellationToken) =>
|
await ApplicationController.Instance.Tasks.Execute("Loading G-Code".Localize(), Printer, (reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
var progressStatus = new ProgressStatus();
|
var progressStatus = new ProgressStatus();
|
||||||
reporter.Report(progressStatus);
|
reporter.Report(progressStatus);
|
||||||
|
|
||||||
this.LoadGCode(stream, cancellationToken, (progress0To1, status) =>
|
this.LoadGCode(stream, cancellationTokenSource.Token, (progress0To1, status) =>
|
||||||
{
|
{
|
||||||
progressStatus.Status = status;
|
progressStatus.Status = status;
|
||||||
progressStatus.Progress0To1 = progress0To1;
|
progressStatus.Progress0To1 = progress0To1;
|
||||||
|
|
@ -330,7 +330,7 @@ namespace MatterHackers.MatterControl
|
||||||
await insertionGroup.LoadingItemsTask;
|
await insertionGroup.LoadingItemsTask;
|
||||||
|
|
||||||
// Persist changes
|
// Persist changes
|
||||||
await this.SaveChanges(null, CancellationToken.None);
|
await this.SaveChanges(null, null);
|
||||||
|
|
||||||
// Slice and print
|
// Slice and print
|
||||||
await ApplicationController.Instance.PrintPart(
|
await ApplicationController.Instance.PrintPart(
|
||||||
|
|
@ -650,9 +650,9 @@ namespace MatterHackers.MatterControl
|
||||||
/// Persists modified meshes to assets and saves pending changes back to the EditContext
|
/// Persists modified meshes to assets and saves pending changes back to the EditContext
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="progress">Allows for progress reporting</param>
|
/// <param name="progress">Allows for progress reporting</param>
|
||||||
/// <param name="cancellationToken">Allows for cancellation during processing</param>
|
/// <param name="cancellationTokenSource">Allows for cancellation during processing</param>
|
||||||
/// <returns>A task representing success</returns>
|
/// <returns>A task representing success</returns>
|
||||||
public async Task SaveChanges(IProgress<ProgressStatus> progress, CancellationToken cancellationToken)
|
public async Task SaveChanges(IProgress<ProgressStatus> progress, CancellationTokenSource cancellationTokenSource)
|
||||||
{
|
{
|
||||||
var progressStatus = new ProgressStatus()
|
var progressStatus = new ProgressStatus()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ namespace MatterHackers.MatterControl
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Execute(string taskTitle, object owner, Func<IProgress<ProgressStatus>, CancellationToken, Task> func, RunningTaskOptions taskActions = null)
|
public Task Execute(string taskTitle, object owner, Func<IProgress<ProgressStatus>, CancellationTokenSource, Task> func, RunningTaskOptions taskActions = null)
|
||||||
{
|
{
|
||||||
var tokenSource = new CancellationTokenSource();
|
var tokenSource = new CancellationTokenSource();
|
||||||
|
|
||||||
|
|
@ -117,7 +117,7 @@ namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await func?.Invoke(taskDetails, tokenSource.Token);
|
await func?.Invoke(taskDetails, tokenSource);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
Task LoadLibraryContent(ILibraryItem libraryItem);
|
Task LoadLibraryContent(ILibraryItem libraryItem);
|
||||||
|
|
||||||
Task SaveChanges(IProgress<ProgressStatus> progress, CancellationToken cancellationToken);
|
Task SaveChanges(IProgress<ProgressStatus> progress, CancellationTokenSource cancellationToken);
|
||||||
|
|
||||||
// TODO: Isolate printer specifics from ISceneContext
|
// TODO: Isolate printer specifics from ISceneContext
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||||
originalEditContext = printer.Bed.EditContext;
|
originalEditContext = printer.Bed.EditContext;
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
printer.Bed.SaveChanges(null, CancellationToken.None);
|
printer.Bed.SaveChanges(null, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
// loop until we are done calibrating
|
// loop until we are done calibrating
|
||||||
|
|
|
||||||
|
|
@ -230,12 +230,12 @@ namespace MatterHackers.MatterControl
|
||||||
ApplicationController.Instance.Tasks.Execute(
|
ApplicationController.Instance.Tasks.Execute(
|
||||||
"Saving".Localize() + "...",
|
"Saving".Localize() + "...",
|
||||||
printer,
|
printer,
|
||||||
async (reporter, cancellationToken) =>
|
async (reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
string path = openParams.FolderPath;
|
string path = openParams.FolderPath;
|
||||||
if (!string.IsNullOrEmpty(path))
|
if (!string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
await exportPlugin.Generate(libraryItems, path, reporter, cancellationToken);
|
await exportPlugin.Generate(libraryItems, path, reporter, cancellationTokenSource.Token);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -264,7 +264,7 @@ namespace MatterHackers.MatterControl
|
||||||
ApplicationController.Instance.Tasks.Execute(
|
ApplicationController.Instance.Tasks.Execute(
|
||||||
"Exporting".Localize() + "...",
|
"Exporting".Localize() + "...",
|
||||||
printer,
|
printer,
|
||||||
async (reporter, cancellationToken) =>
|
async (reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
string extension = Path.GetExtension(savePath);
|
string extension = Path.GetExtension(savePath);
|
||||||
if (!extension.Equals(targetExtension, StringComparison.OrdinalIgnoreCase))
|
if (!extension.Equals(targetExtension, StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
@ -281,7 +281,7 @@ namespace MatterHackers.MatterControl
|
||||||
gCodeExport.CenterOnBed = centerOnBed;
|
gCodeExport.CenterOnBed = centerOnBed;
|
||||||
}
|
}
|
||||||
|
|
||||||
exportErrors = await exportPlugin.Generate(libraryItems, savePath, reporter, cancellationToken);
|
exportErrors = await exportPlugin.Generate(libraryItems, savePath, reporter, cancellationTokenSource.Token);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exportErrors == null || exportErrors.Count == 0)
|
if (exportErrors == null || exportErrors.Count == 0)
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -263,8 +263,9 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
return Task.CompletedTask;
|
return base.Rebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +86,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
this.Mesh = null;
|
this.Mesh = null;
|
||||||
this.Invalidate(InvalidateType.Children);
|
this.Invalidate(InvalidateType.Children);
|
||||||
return Task.CompletedTask;
|
return base.Rebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MatterHackers.Agg;
|
using MatterHackers.Agg;
|
||||||
using MatterHackers.Agg.Platform;
|
using MatterHackers.Agg.Platform;
|
||||||
|
|
@ -88,6 +89,19 @@ namespace MatterHackers.MatterControl.Plugins.Lithophane
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CancellationTokenSource cancellationToken;
|
||||||
|
|
||||||
|
public bool IsBuilding => this.cancellationToken != null;
|
||||||
|
|
||||||
|
public void CancelBuild()
|
||||||
|
{
|
||||||
|
var threadSafe = this.cancellationToken;
|
||||||
|
if (threadSafe != null)
|
||||||
|
{
|
||||||
|
threadSafe.Cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override Task Rebuild()
|
public override Task Rebuild()
|
||||||
{
|
{
|
||||||
this.DebugDepth("Rebuild");
|
this.DebugDepth("Rebuild");
|
||||||
|
|
@ -110,8 +124,9 @@ namespace MatterHackers.MatterControl.Plugins.Lithophane
|
||||||
|
|
||||||
var rebuildLocks = this.RebuilLockAll();
|
var rebuildLocks = this.RebuilLockAll();
|
||||||
|
|
||||||
ApplicationController.Instance.Tasks.Execute("Generating Lithophane".Localize(), null, (reporter, cancellationToken) =>
|
ApplicationController.Instance.Tasks.Execute("Generating Lithophane".Localize(), null, (reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
|
this.cancellationToken = cancellationTokenSource as CancellationTokenSource;
|
||||||
var generatedMesh = Lithophane.Generate(
|
var generatedMesh = Lithophane.Generate(
|
||||||
new Lithophane.ImageBufferImageData(activeImage, this.Width),
|
new Lithophane.ImageBufferImageData(activeImage, this.Width),
|
||||||
this.Height,
|
this.Height,
|
||||||
|
|
@ -132,16 +147,18 @@ namespace MatterHackers.MatterControl.Plugins.Lithophane
|
||||||
// Apply offset
|
// Apply offset
|
||||||
this.Matrix *= Matrix4X4.CreateTranslation(-this.ImageOffset);
|
this.Matrix *= Matrix4X4.CreateTranslation(-this.ImageOffset);
|
||||||
|
|
||||||
|
this.cancellationToken = null;
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
});
|
});
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return base.Rebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,14 +84,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
return ApplicationController.Instance.Tasks.Execute(
|
return ApplicationController.Instance.Tasks.Execute(
|
||||||
"Combine".Localize(),
|
"Combine".Localize(),
|
||||||
null,
|
null,
|
||||||
(reporter, cancellationToken) =>
|
(reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
var progressStatus = new ProgressStatus();
|
var progressStatus = new ProgressStatus();
|
||||||
reporter.Report(progressStatus);
|
reporter.Report(progressStatus);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Combine(cancellationToken, reporter);
|
Combine(cancellationTokenSource.Token, reporter);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
@ -100,10 +100,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return base.Rebuild();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -194,10 +194,11 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
Matrix = currentMatrix;
|
Matrix = currentMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return base.Rebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -120,6 +120,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,6 +142,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -200,8 +202,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
||||||
return Task.CompletedTask;
|
return base.Rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override AxisAlignedBoundingBox GetAxisAlignedBoundingBox(Matrix4X4 matrix)
|
public override AxisAlignedBoundingBox GetAxisAlignedBoundingBox(Matrix4X4 matrix)
|
||||||
|
|
|
||||||
|
|
@ -78,14 +78,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
{
|
{
|
||||||
var rebuildLocks = this.RebuilLockAll();
|
var rebuildLocks = this.RebuilLockAll();
|
||||||
|
|
||||||
return ApplicationController.Instance.Tasks.Execute("Intersection".Localize(), null, (reporter, cancellationToken) =>
|
return ApplicationController.Instance.Tasks.Execute("Intersection".Localize(), null, (reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
var progressStatus = new ProgressStatus();
|
var progressStatus = new ProgressStatus();
|
||||||
reporter.Report(progressStatus);
|
reporter.Report(progressStatus);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Intersect(cancellationToken, reporter);
|
Intersect(cancellationTokenSource.Token, reporter);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
@ -94,9 +94,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
return Task.CompletedTask;
|
return base.Rebuild();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
this.Matrix = oldMatrix;
|
this.Matrix = oldMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
Matrix = currentMatrix;
|
Matrix = currentMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ namespace MatterHackers.MatterControl.Library
|
||||||
|
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -386,6 +386,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLock.Dispose();
|
rebuildLock.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
|
|
||||||
SourceContainer.Visible = false;
|
SourceContainer.Visible = false;
|
||||||
rebuildLock.Dispose();
|
rebuildLock.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLock.Dispose();
|
rebuildLock.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
|
||||||
|
|
@ -227,6 +227,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,19 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CancellationTokenSource cancellationToken;
|
||||||
|
|
||||||
|
public bool IsBuilding => this.cancellationToken != null;
|
||||||
|
|
||||||
|
public void CancelBuild()
|
||||||
|
{
|
||||||
|
var threadSafe = this.cancellationToken;
|
||||||
|
if (threadSafe != null)
|
||||||
|
{
|
||||||
|
threadSafe.Cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override Task Rebuild()
|
public override Task Rebuild()
|
||||||
{
|
{
|
||||||
this.DebugDepth("Rebuild");
|
this.DebugDepth("Rebuild");
|
||||||
|
|
@ -197,8 +210,9 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
return ApplicationController.Instance.Tasks.Execute(
|
return ApplicationController.Instance.Tasks.Execute(
|
||||||
"Curve".Localize(),
|
"Curve".Localize(),
|
||||||
null,
|
null,
|
||||||
(reporter, cancellationToken) =>
|
(reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
|
this.cancellationToken = cancellationTokenSource as CancellationTokenSource;
|
||||||
var sourceAabb = this.SourceContainer.GetAxisAlignedBoundingBox();
|
var sourceAabb = this.SourceContainer.GetAxisAlignedBoundingBox();
|
||||||
|
|
||||||
var radius = diameter / 2;
|
var radius = diameter / 2;
|
||||||
|
|
@ -295,10 +309,12 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
list.AddRange(curvedChildren);
|
list.AddRange(curvedChildren);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.cancellationToken = null;
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -182,6 +182,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix | additonalInvalidate));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix | additonalInvalidate));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix | additonalInvalidate));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix | additonalInvalidate));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -370,6 +370,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLock.Dispose();
|
rebuildLock.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -415,6 +415,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
rebuildLock.Dispose();
|
rebuildLock.Dispose();
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLock.Dispose();
|
rebuildLock.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
this.Mesh = this.VertexSource.Extrude(Constants.PathPolygonsHeight);
|
this.Mesh = this.VertexSource.Extrude(Constants.PathPolygonsHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
{
|
{
|
||||||
rebuildLock.Dispose();
|
rebuildLock.Dispose();
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,14 +83,14 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
return ApplicationController.Instance.Tasks.Execute(
|
return ApplicationController.Instance.Tasks.Execute(
|
||||||
operationName,
|
operationName,
|
||||||
null,
|
null,
|
||||||
(reporter, cancellationToken) =>
|
(reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
var progressStatus = new ProgressStatus();
|
var progressStatus = new ProgressStatus();
|
||||||
reporter.Report(progressStatus);
|
reporter.Report(progressStatus);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Merge(reporter, cancellationToken);
|
Merge(reporter, cancellationTokenSource.Token);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
@ -102,6 +102,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
|
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,19 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CancellationTokenSource cancellationToken;
|
||||||
|
|
||||||
|
public bool IsBuilding => this.cancellationToken != null;
|
||||||
|
|
||||||
|
public void CancelBuild()
|
||||||
|
{
|
||||||
|
var threadSafe = this.cancellationToken;
|
||||||
|
if (threadSafe != null)
|
||||||
|
{
|
||||||
|
threadSafe.Cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override Task Rebuild()
|
public override Task Rebuild()
|
||||||
{
|
{
|
||||||
this.DebugDepth("Rebuild");
|
this.DebugDepth("Rebuild");
|
||||||
|
|
@ -176,8 +189,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
return ApplicationController.Instance.Tasks.Execute(
|
return ApplicationController.Instance.Tasks.Execute(
|
||||||
"Revolve".Localize(),
|
"Revolve".Localize(),
|
||||||
null,
|
null,
|
||||||
(reporter, cancellationToken) =>
|
(reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
|
this.cancellationToken = cancellationTokenSource as CancellationTokenSource;
|
||||||
var vertexSource = this.VertexSource;
|
var vertexSource = this.VertexSource;
|
||||||
var pathBounds = vertexSource.GetBounds();
|
var pathBounds = vertexSource.GetBounds();
|
||||||
vertexSource = vertexSource.Translate(-pathBounds.Left - axisPosition, 0);
|
vertexSource = vertexSource.Translate(-pathBounds.Left - axisPosition, 0);
|
||||||
|
|
@ -197,9 +211,11 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
|
|
||||||
Mesh = mesh;
|
Mesh = mesh;
|
||||||
|
|
||||||
|
this.cancellationToken = null;
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLock.Dispose();
|
rebuildLock.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
{
|
{
|
||||||
rebuildLock.Dispose();
|
rebuildLock.Dispose();
|
||||||
this.Invalidate(InvalidateType.DisplayValues);
|
this.Invalidate(InvalidateType.DisplayValues);
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
|
||||||
});
|
});
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
return TaskBuilder(
|
return TaskBuilder(
|
||||||
"Repair".Localize(),
|
"Repair".Localize(),
|
||||||
(reporter, cancellationToken) =>
|
(reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
SourceContainer.Visible = true;
|
SourceContainer.Visible = true;
|
||||||
RemoveAllButSource();
|
RemoveAllButSource();
|
||||||
|
|
@ -88,7 +88,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
var originalMesh = sourceItem.Mesh;
|
var originalMesh = sourceItem.Mesh;
|
||||||
inititialFaces += originalMesh.Faces.Count;
|
inititialFaces += originalMesh.Faces.Count;
|
||||||
inititialVertices += originalMesh.Vertices.Count;
|
inititialVertices += originalMesh.Vertices.Count;
|
||||||
var repairedMesh = Repair(originalMesh, cancellationToken);
|
var repairedMesh = Repair(originalMesh, cancellationTokenSource.Token);
|
||||||
finalFaces += repairedMesh.Faces.Count;
|
finalFaces += repairedMesh.Faces.Count;
|
||||||
finalVertices += repairedMesh.Vertices.Count;
|
finalVertices += repairedMesh.Vertices.Count;
|
||||||
|
|
||||||
|
|
@ -111,6 +111,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
ItemWithTransform.Matrix = RotationMatrix;
|
ItemWithTransform.Matrix = RotationMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
|
||||||
|
|
@ -297,6 +297,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
|
||||||
|
|
@ -373,6 +373,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
|
|
||||||
|
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
|
|
||||||
scene.SelectedItem = this;
|
scene.SelectedItem = this;
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
parent?.Invalidate(new InvalidateArgs(parent, InvalidateType.Children));
|
parent?.Invalidate(new InvalidateArgs(parent, InvalidateType.Children));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -228,6 +228,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
|
|
||||||
parentLock?.Dispose();
|
parentLock?.Dispose();
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
parent?.Invalidate(new InvalidateArgs(parent, InvalidateType.Children));
|
parent?.Invalidate(new InvalidateArgs(parent, InvalidateType.Children));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
ItemWithTransform.Matrix = Matrix4X4.CreateTranslation(Translation);
|
ItemWithTransform.Matrix = Matrix4X4.CreateTranslation(Translation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -326,6 +326,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -259,6 +259,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
rebuildLock.Dispose();
|
rebuildLock.Dispose();
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -146,8 +146,11 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if any of our parest are re-bulding cancel it as we just changed and they need to start over
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
|
||||||
|
return base.Rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateControls(PublicPropertyChange change)
|
public void UpdateControls(PublicPropertyChange change)
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
_image = image;
|
_image = image;
|
||||||
|
|
||||||
// send the invalidate on image change
|
// send the invalidate on image change
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Image));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Image));
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -228,6 +228,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
{
|
{
|
||||||
public class OperationSourceContainerObject3D : Object3D
|
public class OperationSourceContainerObject3D : Object3D
|
||||||
{
|
{
|
||||||
public static Func<string, Func<IProgress<ProgressStatus>, CancellationToken, Task>, Task> TaskBuilder { get; set; } =
|
public static Func<string, Func<IProgress<ProgressStatus>, CancellationTokenSource, Task>, Task> TaskBuilder { get; set; } =
|
||||||
(name, func) => Task.Run(() => func(null, CancellationToken.None));
|
(name, func) => Task.Run(() => func(null, null));
|
||||||
|
|
||||||
public override Mesh Mesh
|
public override Mesh Mesh
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -232,6 +232,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
UpdateTexture();
|
UpdateTexture();
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -186,6 +186,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
rebuildLock.Dispose();
|
rebuildLock.Dispose();
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
this.Mesh = this.VertexSource.Extrude(Constants.PathPolygonsHeight);
|
this.Mesh = this.VertexSource.Extrude(Constants.PathPolygonsHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
Invalidate(InvalidateType.DisplayValues);
|
Invalidate(InvalidateType.DisplayValues);
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,11 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Create(IProgress<ProgressStatus> progress, CancellationToken cancellationToken)
|
public Task Create(IProgress<ProgressStatus> progress, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return Create(progress, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Create(IProgress<ProgressStatus> progress, CancellationTokenSource cancellationTokenSource)
|
||||||
{
|
{
|
||||||
var selectedItem = scene.SelectedItem;
|
var selectedItem = scene.SelectedItem;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,11 +80,11 @@ namespace MatterControlLib
|
||||||
return ApplicationController.Instance.Tasks.Execute(
|
return ApplicationController.Instance.Tasks.Execute(
|
||||||
"Preparing help index".Localize(),
|
"Preparing help index".Localize(),
|
||||||
null,
|
null,
|
||||||
(progress, cancellationToken) =>
|
(progress, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
string relativePath = System.IO.Path.Combine("OemSettings", "help-docs.zip");
|
string relativePath = System.IO.Path.Combine("OemSettings", "help-docs.zip");
|
||||||
|
|
||||||
IndexZipFile(relativePath, progress, cancellationToken);
|
IndexZipFile(relativePath, progress, cancellationTokenSource.Token);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ namespace MatterHackers.MatterControl.Library.Export
|
||||||
Printer,
|
Printer,
|
||||||
(reporter, cancellationToken2) =>
|
(reporter, cancellationToken2) =>
|
||||||
{
|
{
|
||||||
return Slicer.SliceItem(loadedItem, gcodePath, Printer, reporter, cancellationToken2);
|
return Slicer.SliceItem(loadedItem, gcodePath, Printer, reporter, cancellationToken2.Token);
|
||||||
});
|
});
|
||||||
|
|
||||||
Printer.Settings.SetValue(SettingsKey.spiral_vase, oldSpiralVaseSetting ? "1" : "0");
|
Printer.Settings.SetValue(SettingsKey.spiral_vase, oldSpiralVaseSetting ? "1" : "0");
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,11 @@ using MatterHackers.VectorMath;
|
||||||
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
{
|
{
|
||||||
[ShowUpdateButton(false)]
|
[ShowUpdateButton(false)]
|
||||||
public class CombineObject3D_2 : OperationSourceContainerObject3D, IPropertyGridModifier
|
public class CombineObject3D_2 : OperationSourceContainerObject3D, IPropertyGridModifier, IBuildsOnThread
|
||||||
{
|
{
|
||||||
public CombineObject3D_2()
|
private CancellationTokenSource cancellationToken;
|
||||||
|
|
||||||
|
public CombineObject3D_2()
|
||||||
{
|
{
|
||||||
Name = "Combine";
|
Name = "Combine";
|
||||||
}
|
}
|
||||||
|
|
@ -67,6 +69,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
private IplicitSurfaceMethod MeshAnalysis { get; set; }
|
private IplicitSurfaceMethod MeshAnalysis { get; set; }
|
||||||
private ProcessingResolution InputResolution { get; set; } = ProcessingResolution._64;
|
private ProcessingResolution InputResolution { get; set; } = ProcessingResolution._64;
|
||||||
#endif
|
#endif
|
||||||
|
public bool IsBuilding => this.cancellationToken != null;
|
||||||
|
|
||||||
public override Task Rebuild()
|
public override Task Rebuild()
|
||||||
{
|
{
|
||||||
this.DebugDepth("Rebuild");
|
this.DebugDepth("Rebuild");
|
||||||
|
|
@ -76,22 +80,25 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
return ApplicationController.Instance.Tasks.Execute(
|
return ApplicationController.Instance.Tasks.Execute(
|
||||||
"Combine".Localize(),
|
"Combine".Localize(),
|
||||||
null,
|
null,
|
||||||
(reporter, cancellationToken) =>
|
(reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
|
this.cancellationToken = cancellationTokenSource as CancellationTokenSource;
|
||||||
var progressStatus = new ProgressStatus();
|
var progressStatus = new ProgressStatus();
|
||||||
reporter.Report(progressStatus);
|
reporter.Report(progressStatus);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Combine(cancellationToken, reporter);
|
Combine(cancellationTokenSource.Token, reporter);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.cancellationToken = null;
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
@ -197,5 +204,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
change.SetRowVisible(nameof(MeshAnalysis), () => Processing != ProcessingModes.Polygons);
|
change.SetRowVisible(nameof(MeshAnalysis), () => Processing != ProcessingModes.Polygons);
|
||||||
change.SetRowVisible(nameof(InputResolution), () => Processing != ProcessingModes.Polygons && MeshAnalysis == IplicitSurfaceMethod.Grid);
|
change.SetRowVisible(nameof(InputResolution), () => Processing != ProcessingModes.Polygons && MeshAnalysis == IplicitSurfaceMethod.Grid);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void CancelBuild()
|
||||||
|
{
|
||||||
|
var threadSafe = this.cancellationToken;
|
||||||
|
if(threadSafe != null)
|
||||||
|
{
|
||||||
|
threadSafe.Cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,19 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
private ProcessingResolution InputResolution { get; set; } = ProcessingResolution._64;
|
private ProcessingResolution InputResolution { get; set; } = ProcessingResolution._64;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
private CancellationTokenSource cancellationToken;
|
||||||
|
|
||||||
|
public bool IsBuilding => this.cancellationToken != null;
|
||||||
|
|
||||||
|
public void CancelBuild()
|
||||||
|
{
|
||||||
|
var threadSafe = this.cancellationToken;
|
||||||
|
if (threadSafe != null)
|
||||||
|
{
|
||||||
|
threadSafe.Cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override Task Rebuild()
|
public override Task Rebuild()
|
||||||
{
|
{
|
||||||
this.DebugDepth("Rebuild");
|
this.DebugDepth("Rebuild");
|
||||||
|
|
@ -77,22 +90,25 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
return ApplicationController.Instance.Tasks.Execute(
|
return ApplicationController.Instance.Tasks.Execute(
|
||||||
"Intersection".Localize(),
|
"Intersection".Localize(),
|
||||||
null,
|
null,
|
||||||
(reporter, cancellationToken) =>
|
(reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
|
this.cancellationToken = cancellationTokenSource as CancellationTokenSource;
|
||||||
var progressStatus = new ProgressStatus();
|
var progressStatus = new ProgressStatus();
|
||||||
reporter.Report(progressStatus);
|
reporter.Report(progressStatus);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Intersect(cancellationToken, reporter);
|
Intersect(cancellationTokenSource.Token, reporter);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.cancellationToken = null;
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -202,11 +202,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
var rebuildLocks = this.RebuilLockAll();
|
var rebuildLocks = this.RebuilLockAll();
|
||||||
|
|
||||||
// spin up a task to calculate the paint
|
// spin up a task to calculate the paint
|
||||||
return ApplicationController.Instance.Tasks.Execute("Replacing".Localize(), null, (reporter, cancellationToken) =>
|
return ApplicationController.Instance.Tasks.Execute("Replacing".Localize(), null, (reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SubtractAndReplace(cancellationToken, reporter);
|
SubtractAndReplace(cancellationTokenSource.Token, reporter);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
@ -215,6 +215,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,16 +129,32 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CancellationTokenSource cancellationToken;
|
||||||
|
|
||||||
|
public bool IsBuilding => this.cancellationToken != null;
|
||||||
|
|
||||||
|
public void CancelBuild()
|
||||||
|
{
|
||||||
|
var threadSafe = this.cancellationToken;
|
||||||
|
if (threadSafe != null)
|
||||||
|
{
|
||||||
|
threadSafe.Cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override Task Rebuild()
|
public override Task Rebuild()
|
||||||
{
|
{
|
||||||
var rebuildLocks = this.RebuilLockAll();
|
var rebuildLocks = this.RebuilLockAll();
|
||||||
|
|
||||||
// spin up a task to calculate the paint
|
// spin up a task to calculate the paint
|
||||||
return ApplicationController.Instance.Tasks.Execute("Replacing".Localize(), null, (reporter, cancellationToken) =>
|
return ApplicationController.Instance.Tasks.Execute("Replacing".Localize(),
|
||||||
|
null,
|
||||||
|
(reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
|
this.cancellationToken = cancellationTokenSource as CancellationTokenSource;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SubtractAndReplace(cancellationToken, reporter);
|
SubtractAndReplace(cancellationTokenSource.Token, reporter);
|
||||||
var newComputedChildren = new SelectedChildren();
|
var newComputedChildren = new SelectedChildren();
|
||||||
|
|
||||||
foreach (var id in SelectedChildren)
|
foreach (var id in SelectedChildren)
|
||||||
|
|
@ -152,9 +168,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.cancellationToken = null;
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,14 +85,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
return ApplicationController.Instance.Tasks.Execute(
|
return ApplicationController.Instance.Tasks.Execute(
|
||||||
"Subtract".Localize(),
|
"Subtract".Localize(),
|
||||||
null,
|
null,
|
||||||
(reporter, cancellationToken) =>
|
(reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
var progressStatus = new ProgressStatus();
|
var progressStatus = new ProgressStatus();
|
||||||
reporter.Report(progressStatus);
|
reporter.Report(progressStatus);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Subtract(cancellationToken, reporter);
|
Subtract(cancellationTokenSource.Token, reporter);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
@ -101,6 +101,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ using MatterHackers.VectorMath;
|
||||||
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
{
|
{
|
||||||
[ShowUpdateButton(false)]
|
[ShowUpdateButton(false)]
|
||||||
public class SubtractObject3D_2 : OperationSourceContainerObject3D, ISelectableChildContainer, ICustomEditorDraw, IPropertyGridModifier
|
public class SubtractObject3D_2 : OperationSourceContainerObject3D, ISelectableChildContainer, ICustomEditorDraw, IPropertyGridModifier, IBuildsOnThread
|
||||||
{
|
{
|
||||||
public SubtractObject3D_2()
|
public SubtractObject3D_2()
|
||||||
{
|
{
|
||||||
|
|
@ -130,6 +130,19 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CancellationTokenSource cancellationToken;
|
||||||
|
|
||||||
|
public bool IsBuilding => this.cancellationToken != null;
|
||||||
|
|
||||||
|
public void CancelBuild()
|
||||||
|
{
|
||||||
|
var threadSafe = this.cancellationToken;
|
||||||
|
if (threadSafe != null)
|
||||||
|
{
|
||||||
|
threadSafe.Cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override Task Rebuild()
|
public override Task Rebuild()
|
||||||
{
|
{
|
||||||
this.DebugDepth("Rebuild");
|
this.DebugDepth("Rebuild");
|
||||||
|
|
@ -139,22 +152,25 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
return ApplicationController.Instance.Tasks.Execute(
|
return ApplicationController.Instance.Tasks.Execute(
|
||||||
"Subtract".Localize(),
|
"Subtract".Localize(),
|
||||||
null,
|
null,
|
||||||
(reporter, cancellationToken) =>
|
(reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
|
this.cancellationToken = cancellationTokenSource as CancellationTokenSource;
|
||||||
var progressStatus = new ProgressStatus();
|
var progressStatus = new ProgressStatus();
|
||||||
reporter.Report(progressStatus);
|
reporter.Report(progressStatus);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Subtract(cancellationToken, reporter);
|
Subtract(cancellationTokenSource.Token, reporter);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.cancellationToken = null;
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,14 +106,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
return ApplicationController.Instance.Tasks.Execute(
|
return ApplicationController.Instance.Tasks.Execute(
|
||||||
"Subtract".Localize(),
|
"Subtract".Localize(),
|
||||||
null,
|
null,
|
||||||
(reporter, cancellationToken) =>
|
(reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
var progressStatus = new ProgressStatus();
|
var progressStatus = new ProgressStatus();
|
||||||
reporter.Report(progressStatus);
|
reporter.Report(progressStatus);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Subtract(cancellationToken, reporter);
|
Subtract(cancellationTokenSource.Token, reporter);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
@ -133,6 +133,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
rebuildLocks.Dispose();
|
rebuildLocks.Dispose();
|
||||||
|
this.CancelAllParentBuilding();
|
||||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
await ApplicationController.Instance.Tasks.Execute(
|
await ApplicationController.Instance.Tasks.Execute(
|
||||||
"Ungroup".Localize(),
|
"Ungroup".Localize(),
|
||||||
null,
|
null,
|
||||||
(reporter, cancellationToken) =>
|
(reporter, cancellationTokenSource) =>
|
||||||
{
|
{
|
||||||
var progressStatus = new ProgressStatus();
|
var progressStatus = new ProgressStatus();
|
||||||
reporter.Report(progressStatus);
|
reporter.Report(progressStatus);
|
||||||
|
|
@ -90,16 +90,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
// try to cut it up into multiple meshes
|
// try to cut it up into multiple meshes
|
||||||
progressStatus.Status = "Split".Localize();
|
progressStatus.Status = "Split".Localize();
|
||||||
|
|
||||||
var cleanMesh = selectedItem.Mesh.Copy(cancellationToken);
|
var cleanMesh = selectedItem.Mesh.Copy(cancellationTokenSource.Token);
|
||||||
cleanMesh.MergeVertices(.01);
|
cleanMesh.MergeVertices(.01);
|
||||||
|
|
||||||
var discreetMeshes = CreateDiscreteMeshes.SplitVolumesIntoMeshes(cleanMesh, cancellationToken, (double progress0To1, string processingState) =>
|
var discreetMeshes = CreateDiscreteMeshes.SplitVolumesIntoMeshes(cleanMesh, cancellationTokenSource.Token, (double progress0To1, string processingState) =>
|
||||||
{
|
{
|
||||||
progressStatus.Progress0To1 = .5 + progress0To1 * .5;
|
progressStatus.Progress0To1 = .5 + progress0To1 * .5;
|
||||||
progressStatus.Status = processingState;
|
progressStatus.Status = processingState;
|
||||||
reporter.Report(progressStatus);
|
reporter.Report(progressStatus);
|
||||||
});
|
});
|
||||||
if (cancellationToken.IsCancellationRequested)
|
if (cancellationTokenSource.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 17fb182f8ef221a9fbe94eb831cef9956c6c1ba6
|
Subproject commit dc55feeb1e043b0772aa2c21b4d6947e1cccc14f
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit e996ffa5eb793d8b7e4d832b9d1b33e08bf0c152
|
Subproject commit 8c801ba65845521e2a0e13a00f318952caa80336
|
||||||
Loading…
Add table
Add a link
Reference in a new issue