Adding some progress reporting to subtract
Moved ProgressStatus to agg
This commit is contained in:
parent
c023ee47eb
commit
f9378f4405
8 changed files with 35 additions and 12 deletions
|
|
@ -85,10 +85,4 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ProgressStatus : EventArgs
|
||||
{
|
||||
public string Status { get; set; }
|
||||
public double Progress0To1 { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
|||
|
||||
private void ProcessBooleans(IObject3D group)
|
||||
{
|
||||
// spin up a task to remove holes from the objects in the group
|
||||
// spin up a task to calculate the paint
|
||||
ApplicationController.Instance.Tasks.Execute((reporter, cancelationToken) =>
|
||||
{
|
||||
var progressStatus = new ProgressStatus()
|
||||
|
|
|
|||
|
|
@ -147,11 +147,18 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
|||
tabContainer.AddChild(updateButton);
|
||||
}
|
||||
|
||||
private async void ProcessBooleans(IObject3D group)
|
||||
private void ProcessBooleans(IObject3D group)
|
||||
{
|
||||
// spin up a task to remove holes from the objects in the group
|
||||
await Task.Run(() =>
|
||||
ApplicationController.Instance.Tasks.Execute((reporter, cancelationToken) =>
|
||||
{
|
||||
var progressStatus = new ProgressStatus()
|
||||
{
|
||||
Status = "Processing Booleans"
|
||||
};
|
||||
|
||||
reporter.Report(progressStatus);
|
||||
|
||||
var participants = group.Descendants().Where(o => o.OwnerID == group.ID).ToList();
|
||||
var removeObjects = participants.Where((obj) => obj.OutputType == PrintOutputTypes.Hole).ToList();
|
||||
var keepObjects = participants.Where((obj) => obj.OutputType != PrintOutputTypes.Hole).ToList();
|
||||
|
|
@ -159,27 +166,46 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
|||
if (removeObjects.Any()
|
||||
&& keepObjects.Any())
|
||||
{
|
||||
var totalOpperations = removeObjects.Count() * keepObjects.Count();
|
||||
double amountPerOperation = 1.0 / totalOpperations;
|
||||
double percentCompleted = 0;
|
||||
|
||||
foreach (var remove in removeObjects)
|
||||
{
|
||||
foreach (var keep in keepObjects)
|
||||
{
|
||||
progressStatus.Status = "Copy Remove";
|
||||
reporter.Report(progressStatus);
|
||||
var transformedRemove = Mesh.Copy(remove.Mesh, CancellationToken.None);
|
||||
transformedRemove.Transform(remove.WorldMatrix());
|
||||
|
||||
progressStatus.Status = "Copy Keep";
|
||||
reporter.Report(progressStatus);
|
||||
var transformedKeep = Mesh.Copy(keep.Mesh, CancellationToken.None);
|
||||
transformedKeep.Transform(keep.WorldMatrix());
|
||||
|
||||
transformedKeep = PolygonMesh.Csg.CsgOperations.Subtract(transformedKeep, transformedRemove);
|
||||
progressStatus.Status = "Do CSG";
|
||||
reporter.Report(progressStatus);
|
||||
transformedKeep = PolygonMesh.Csg.CsgOperations.Subtract(transformedKeep, transformedRemove, (csgStatus) =>
|
||||
{
|
||||
progressStatus.Status = csgStatus.Status;
|
||||
reporter.Report(progressStatus);
|
||||
}, cancelationToken);
|
||||
var inverse = keep.WorldMatrix();
|
||||
inverse.Invert();
|
||||
transformedKeep.Transform(inverse);
|
||||
keep.Mesh = transformedKeep;
|
||||
view3DWidget.Invalidate();
|
||||
|
||||
percentCompleted += amountPerOperation;
|
||||
progressStatus.Progress0To1 = percentCompleted;
|
||||
reporter.Report(progressStatus);
|
||||
}
|
||||
|
||||
remove.Visible = false;
|
||||
}
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using MatterHackers.GCodeVisualizer;
|
||||
using MatterHackers.Agg;
|
||||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using Newtonsoft.Json;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
|||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.PrinterControls.PrinterConnections;
|
||||
using MatterHackers.Agg;
|
||||
|
||||
namespace MatterHackers.MatterControl.SetupWizard
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 8ef196a04d1ab2ab8d85d14ce9be1c1926a55666
|
||||
Subproject commit 4c6870cd65cafbf5d677ccfbc47044a3df5e88e3
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit c3bf6f29d625706728891a38ecbf4c2f81996ded
|
||||
Subproject commit f5421fbb01872b3909e8e3d3d0f5c963dd384109
|
||||
Loading…
Add table
Add a link
Reference in a new issue