Merge pull request #2278 from jlewin/design_tools
Convert from ReportProgressRatio to Action<T>
This commit is contained in:
commit
7035752fea
27 changed files with 87 additions and 113 deletions
|
|
@ -139,7 +139,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
public void LoadGCode(string filePath, CancellationToken cancellationToken, ReportProgressRatio<(double,string)> progressReporter)
|
||||
public void LoadGCode(string filePath, CancellationToken cancellationToken, Action<double,string> progressReporter)
|
||||
{
|
||||
this.LoadedGCode = GCodeMemoryFile.Load(filePath, cancellationToken, progressReporter);
|
||||
this.GCodeRenderer = new GCodeRenderer(loadedGCode);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,15 @@
|
|||
using MatterHackers.Agg;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.GCodeVisualizer;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.DataStorage;
|
||||
using MatterHackers.MatterControl.PrinterCommunication.Io;
|
||||
|
|
@ -12,15 +17,6 @@ using MatterHackers.MatterControl.PrintQueue;
|
|||
using MatterHackers.MatterControl.Queue.OptionsMenu;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.PolygonMesh;
|
||||
using MatterHackers.PolygonMesh.Processors;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl
|
|||
thumbnailImage = thumbIcon;
|
||||
}
|
||||
|
||||
public ContentResult CreateItem(ILibraryItem item, ReportProgressRatio<(double ratio, string state)> reporter)
|
||||
public ContentResult CreateItem(ILibraryItem item, Action<double, string> reporter)
|
||||
{
|
||||
System.Diagnostics.Debugger.Break();
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
public interface ISceneContentProvider : IContentProvider
|
||||
{
|
||||
// TODO: Needs to take a progress reporter that is used in the background task which creates the actual IObject3D mesh and children
|
||||
ContentResult CreateItem(ILibraryItem item, ReportProgressRatio<(double ratio, string state)> reporter);
|
||||
ContentResult CreateItem(ILibraryItem item, Action<double, string> reporter);
|
||||
}
|
||||
|
||||
public interface IPrintableContentProvider : IContentProvider
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ namespace MatterHackers.MatterControl
|
|||
private static readonly int MaxFileSize = (OsInformation.OperatingSystem == OSType.Android) ? tooBigAndroid : tooBigDesktop;
|
||||
private static readonly Point2D BigRenderSize = new Point2D(460, 460);
|
||||
|
||||
public ContentResult CreateItem(ILibraryItem item, ReportProgressRatio<(double ratio, string state)> progressReporter)
|
||||
public ContentResult CreateItem(ILibraryItem item, Action<double, string> progressReporter)
|
||||
{
|
||||
var sceneItem = new Object3D()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ either expressed or implied, of the FreeBSD Project.
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.ImageProcessing;
|
||||
|
|
@ -63,7 +62,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
}
|
||||
}
|
||||
|
||||
public static ContentResult CreateContent(this ILibraryContentStream item, ReportProgressRatio<(double ratio, string state)> reporter = null)
|
||||
public static ContentResult CreateContent(this ILibraryContentStream item, Action<double, string> reporter = null)
|
||||
{
|
||||
var contentProvider = ApplicationController.Instance.Library.GetContentProvider(item) as ISceneContentProvider;
|
||||
return contentProvider?.CreateItem(item, reporter);
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
|
||||
namespace MatterHackers.MatterControl.Library
|
||||
{
|
||||
public interface ILibraryContainerLink : ILibraryItem
|
||||
{
|
||||
Task<ILibraryContainer> GetContainer(ReportProgressRatio<(double ratio, string state)> reportProgress);
|
||||
Task<ILibraryContainer> GetContainer(Action<double, string> reportProgress);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.DataConverters3D;
|
||||
|
||||
namespace MatterHackers.MatterControl.Library
|
||||
|
|
@ -45,7 +45,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
{
|
||||
string ContentType { get; }
|
||||
string Category { get; }
|
||||
Task<IObject3D> GetContent(ReportProgressRatio<(double ratio, string state)> reportProgress);
|
||||
Task<IObject3D> GetContent(Action<double, string> reportProgress);
|
||||
void SetContent(IObject3D item);
|
||||
}
|
||||
|
||||
|
|
@ -58,6 +58,6 @@ namespace MatterHackers.MatterControl.Library
|
|||
string ContentType { get; }
|
||||
string FileName { get; }
|
||||
string AssetPath { get; }
|
||||
Task<StreamAndLength> GetContentStream(ReportProgressRatio<(double ratio, string state)> reportProgress);
|
||||
Task<StreamAndLength> GetContentStream(Action<double, string> progress);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ either expressed or implied, of the FreeBSD Project.
|
|||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
|
||||
namespace MatterHackers.MatterControl.Library
|
||||
|
|
@ -56,7 +55,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
|
||||
public bool IsVisible => this.visibilityResolver();
|
||||
|
||||
public Task<ILibraryContainer> GetContainer(ReportProgressRatio<(double ratio, string state)> reportProgress)
|
||||
public Task<ILibraryContainer> GetContainer(Action<double, string> reportProgress)
|
||||
{
|
||||
return Task.FromResult(this.containerCreator());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.Agg.UI;
|
||||
|
||||
|
|
@ -385,7 +384,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
|
||||
public bool UseIncrementedNameDuringTypeChange { get; set; }
|
||||
|
||||
public Task<ILibraryContainer> GetContainer(ReportProgressRatio<(double ratio, string state)> reportProgress)
|
||||
public Task<ILibraryContainer> GetContainer(Action<double, string> reportProgress)
|
||||
{
|
||||
return Task.FromResult<ILibraryContainer>(
|
||||
new FileSystemContainer(this.Path)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ either expressed or implied, of the FreeBSD Project.
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.DataConverters3D;
|
||||
|
||||
namespace MatterHackers.MatterControl.Library
|
||||
|
|
@ -57,7 +56,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
}
|
||||
}
|
||||
|
||||
public Task<StreamAndLength> GetContentStream(ReportProgressRatio<(double ratio, string state)> reportProgress)
|
||||
public Task<StreamAndLength> GetContentStream(Action<double, string> reportProgress)
|
||||
{
|
||||
if (ApplicationController.Instance.IsLoadableFile(this.Path)
|
||||
&& File.Exists(this.Path))
|
||||
|
|
@ -73,7 +72,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
return Task.FromResult<StreamAndLength>(null);
|
||||
}
|
||||
|
||||
public Task<IObject3D> GetContent(ReportProgressRatio<(double ratio, string state)> reportProgress)
|
||||
public Task<IObject3D> GetContent(Action<double, string> reportProgress)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
/// </summary>
|
||||
public Func<IObject3D> Collector { get; }
|
||||
|
||||
public Task<IObject3D> GetContent(ReportProgressRatio<(double ratio, string state)> reportProgress) => Task.FromResult(Collector?.Invoke());
|
||||
public Task<IObject3D> GetContent(Action<double, string> reportProgress) => Task.FromResult(Collector?.Invoke());
|
||||
|
||||
public void SetContent(IObject3D item)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.DataStorage;
|
||||
|
|
@ -64,7 +63,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
|
||||
public bool IsVisible => true;
|
||||
|
||||
public Task<StreamAndLength> GetContentStream(ReportProgressRatio<(double ratio, string state)> reportProgress)
|
||||
public Task<StreamAndLength> GetContentStream(Action<double, string> reportProgress)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
|
|
@ -343,7 +342,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
|
||||
public bool IsVisible { get; set; } = true;
|
||||
|
||||
public Task<ILibraryContainer> GetContainer(ReportProgressRatio<(double ratio, string state)> reportProgress)
|
||||
public Task<ILibraryContainer> GetContainer(Action<double, string> reportProgress)
|
||||
{
|
||||
return Task.FromResult<ILibraryContainer>(
|
||||
new SqliteLibraryContainer(this.ContainerID)
|
||||
|
|
|
|||
|
|
@ -27,12 +27,10 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
|
||||
namespace MatterHackers.MatterControl.Library
|
||||
|
|
@ -67,7 +65,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
}
|
||||
}
|
||||
|
||||
public Task<ILibraryContainer> GetContainer(ReportProgressRatio<(double ratio, string state)> reportProgress)
|
||||
public Task<ILibraryContainer> GetContainer(Action<double, string> reportProgress)
|
||||
{
|
||||
return Task.FromResult<ILibraryContainer>(new ZipMemoryContainer(this.currentDirectory, this.Path));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
/// </summary>
|
||||
public long FileSize { get; private set; }
|
||||
|
||||
public async Task<StreamAndLength> GetContentStream(ReportProgressRatio<(double ratio, string state)> reportProgress)
|
||||
public async Task<StreamAndLength> GetContentStream(Action<double, string> reportProgress)
|
||||
{
|
||||
var memStream = await Task.Run(() =>
|
||||
{
|
||||
|
|
@ -86,7 +86,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
}
|
||||
|
||||
/*
|
||||
public async Task<IObject3D> GetContent(ReportProgressRatio<(double ratio, string state)> reportProgress)
|
||||
public async Task<IObject3D> GetContent(Action<double, string> reportProgress)
|
||||
{
|
||||
var streamAndLength = await GetContentStream(null);
|
||||
IObject3D object3D = Object3D.Load(streamAndLength.Stream, System.IO.Path.GetExtension(Name));
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ either expressed or implied, of the FreeBSD Project.
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
|
|
@ -48,18 +47,18 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
|
||||
ProgressControl processingProgressControl;
|
||||
|
||||
internal void ProgressReporter((double progress0To1, string processingState) progress)
|
||||
internal void ProgressReporter(double progress0To1, string processingState)
|
||||
{
|
||||
if (processingProgressControl == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
processingProgressControl.Visible = progress.progress0To1 != 0;
|
||||
processingProgressControl.RatioComplete = progress.progress0To1;
|
||||
processingProgressControl.ProcessType = progress.processingState;
|
||||
processingProgressControl.Visible = progress0To1 != 0;
|
||||
processingProgressControl.RatioComplete = progress0To1;
|
||||
processingProgressControl.ProcessType = processingState;
|
||||
|
||||
if (progress.progress0To1 == 1)
|
||||
if (progress0To1 == 1)
|
||||
{
|
||||
EndProgress();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ namespace MatterHackers.GCodeVisualizer
|
|||
return ParseFileContents(gcodeContents, cancellationToken, null);
|
||||
}
|
||||
|
||||
public static GCodeMemoryFile Load(Stream fileStream, CancellationToken cancellationToken, ReportProgressRatio<(double ratio, string state)> progressReporter = null)
|
||||
public static GCodeMemoryFile Load(Stream fileStream, CancellationToken cancellationToken, Action<double, string> progressReporter = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -130,7 +130,7 @@ namespace MatterHackers.GCodeVisualizer
|
|||
return null;
|
||||
}
|
||||
|
||||
public static GCodeMemoryFile Load(string filePath, CancellationToken cancellationToken, ReportProgressRatio<(double ratio, string state)> progressReporter)
|
||||
public static GCodeMemoryFile Load(string filePath, CancellationToken cancellationToken, Action<double, string> progressReporter)
|
||||
{
|
||||
if (Path.GetExtension(filePath).ToUpper() == ".GCODE")
|
||||
{
|
||||
|
|
@ -180,7 +180,7 @@ namespace MatterHackers.GCodeVisualizer
|
|||
return crCount + 1;
|
||||
}
|
||||
|
||||
public static GCodeMemoryFile ParseFileContents(string gCodeString, CancellationToken cancellationToken, ReportProgressRatio<(double ratio, string state)> progressReporter)
|
||||
public static GCodeMemoryFile ParseFileContents(string gCodeString, CancellationToken cancellationToken, Action<double, string> progressReporter)
|
||||
{
|
||||
if (gCodeString == null)
|
||||
{
|
||||
|
|
@ -259,7 +259,7 @@ namespace MatterHackers.GCodeVisualizer
|
|||
|
||||
if (progressReporter != null && maxProgressReport.ElapsedMilliseconds > 200)
|
||||
{
|
||||
progressReporter(((double)lineIndex / crCount / 2, ""));
|
||||
progressReporter((double)lineIndex / crCount / 2, "");
|
||||
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
|
|
@ -280,7 +280,7 @@ namespace MatterHackers.GCodeVisualizer
|
|||
return loadedGCodeFile;
|
||||
}
|
||||
|
||||
private void AnalyzeGCodeLines(CancellationToken cancellationToken, ReportProgressRatio<(double ratio, string state)> progressReporter)
|
||||
private void AnalyzeGCodeLines(CancellationToken cancellationToken, Action<double, string> progressReporter)
|
||||
{
|
||||
double feedRateMmPerMin = 0;
|
||||
Vector3 lastPrinterPosition = new Vector3();
|
||||
|
|
@ -334,7 +334,7 @@ namespace MatterHackers.GCodeVisualizer
|
|||
|
||||
if (progressReporter != null && maxProgressReport.ElapsedMilliseconds > 200)
|
||||
{
|
||||
progressReporter((((double) lineIndex / GCodeCommandQueue.Count / 2) + .5, ""));
|
||||
progressReporter(((double) lineIndex / GCodeCommandQueue.Count / 2) + .5, "");
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ 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;
|
||||
using ClipperLib;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
|
|
@ -34,10 +38,6 @@ using MatterHackers.Agg.ImageProcessing;
|
|||
using MatterHackers.MarchingSquares;
|
||||
using MatterHackers.PolygonMesh;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
|
|
@ -47,19 +47,19 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public static class CreateDiscreteMeshes
|
||||
{
|
||||
public static List<Mesh> SplitConnectedIntoMeshes(MeshGroup meshGroupToSplit, CancellationToken cancellationToken, ReportProgressRatio<(double ratio, string state)> reportProgress)
|
||||
public static List<Mesh> SplitConnectedIntoMeshes(MeshGroup meshGroupToSplit, CancellationToken cancellationToken, Action<double, string> reportProgress)
|
||||
{
|
||||
List<Mesh> discreteMeshes = new List<Mesh>();
|
||||
double ratioPerDiscreetMesh = 1.0 / meshGroupToSplit.Meshes.Count;
|
||||
double currentRatioDone = 0;
|
||||
foreach (Mesh mesh in meshGroupToSplit.Meshes)
|
||||
{
|
||||
List<Mesh> discreteVolumes = SplitVolumesIntoMeshes(mesh, cancellationToken, ((double progress0To1, string processingState) progressIn) =>
|
||||
List<Mesh> discreteVolumes = SplitVolumesIntoMeshes(mesh, cancellationToken, (double progress0To1, string processingState) =>
|
||||
{
|
||||
if (reportProgress != null)
|
||||
{
|
||||
double progress = (currentRatioDone + ratioPerDiscreetMesh * progressIn.progress0To1);
|
||||
reportProgress.Invoke((progress, "Split Into Meshes"));
|
||||
double progress = (currentRatioDone + ratioPerDiscreetMesh * progress0To1);
|
||||
reportProgress.Invoke(progress, "Split Into Meshes");
|
||||
}
|
||||
});
|
||||
discreteMeshes.AddRange(discreteVolumes);
|
||||
|
|
@ -70,7 +70,7 @@ namespace MatterHackers.MatterControl
|
|||
return discreteMeshes;
|
||||
}
|
||||
|
||||
public static List<Mesh> SplitVolumesIntoMeshes(Mesh meshToSplit, CancellationToken cancellationToken, ReportProgressRatio<(double ratio, string state)> reportProgress)
|
||||
public static List<Mesh> SplitVolumesIntoMeshes(Mesh meshToSplit, CancellationToken cancellationToken, Action<double, string> reportProgress)
|
||||
{
|
||||
List<Mesh> discreetVolumes = new List<Mesh>();
|
||||
HashSet<Face> facesThatHaveBeenAdded = new HashSet<Face>();
|
||||
|
|
@ -98,16 +98,16 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
if (!facesThatHaveBeenAdded.Contains(faceAttachedToVertex))
|
||||
{
|
||||
// marke that this face has been taken care of
|
||||
// mark that this face has been taken care of
|
||||
facesThatHaveBeenAdded.Add(faceAttachedToVertex);
|
||||
// add it to the list of faces we need to walk
|
||||
attachedFaces.Push(faceAttachedToVertex);
|
||||
|
||||
// Add a new face to the new mesh we are creating.
|
||||
List<Vertex> faceVertices = new List<Vertex>();
|
||||
var faceVertices = new List<IVertex>();
|
||||
foreach (FaceEdge faceEdgeToAdd in faceAttachedToVertex.FaceEdges())
|
||||
{
|
||||
Vertex newVertex = meshFromCurrentVolume.CreateVertex(faceEdgeToAdd.firstVertex.Position, CreateOption.CreateNew, SortOption.WillSortLater);
|
||||
var newVertex = meshFromCurrentVolume.CreateVertex(faceEdgeToAdd.firstVertex.Position, CreateOption.CreateNew, SortOption.WillSortLater);
|
||||
faceVertices.Add(newVertex);
|
||||
}
|
||||
|
||||
|
|
@ -125,14 +125,14 @@ namespace MatterHackers.MatterControl
|
|||
if (reportProgress != null)
|
||||
{
|
||||
double progress = faceIndex / (double)meshToSplit.Faces.Count;
|
||||
reportProgress((progress, "Split Into Meshes"));
|
||||
reportProgress(progress, "Split Into Meshes");
|
||||
}
|
||||
}
|
||||
|
||||
return discreetVolumes;
|
||||
}
|
||||
|
||||
public static Mesh[] SplitIntoMeshesOnOrthographicZ(Mesh meshToSplit, Vector3 buildVolume, ReportProgressRatio<(double ratio, string state)> reportProgress)
|
||||
public static Mesh[] SplitIntoMeshesOnOrthographicZ(Mesh meshToSplit, Vector3 buildVolume, Action<double, string> reportProgress)
|
||||
{
|
||||
// check if the part is bigger than the build plate (if it is we need to use that as our size)
|
||||
AxisAlignedBoundingBox partBounds = meshToSplit.GetAxisAlignedBoundingBox();
|
||||
|
|
@ -150,7 +150,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
PolygonMesh.Rendering.OrthographicZProjection.DrawTo(partPlate.NewGraphics2D(), meshToSplit, renderOffset, scaleFactor, RGBA_Bytes.White);
|
||||
|
||||
reportProgress?.Invoke((.2, ""));
|
||||
reportProgress?.Invoke(.2, "");
|
||||
|
||||
//ImageIO.SaveImageData("test part plate 0.png", partPlate);
|
||||
// expand the bounds a bit so that we can collect all the vertices and polygons within each bound
|
||||
|
|
@ -188,7 +188,7 @@ namespace MatterHackers.MatterControl
|
|||
graphics2D.Render(PlatingHelper.PolygonToPathStorage(polygon), new RGBA_Bytes(rand.Next(128, 255), rand.Next(128, 255), rand.Next(128, 255)));
|
||||
}
|
||||
|
||||
reportProgress?.Invoke((.5, ""));
|
||||
reportProgress?.Invoke(.5, "");
|
||||
|
||||
//ImageIO.SaveImageData("test part plate 2.png", partPlate);
|
||||
|
||||
|
|
@ -213,10 +213,10 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
if (PointInPolygon(discreteAreas[areaIndex], new IntPoint((int)position.x, (int)position.y)))
|
||||
{
|
||||
List<Vertex> faceVertices = new List<Vertex>();
|
||||
var faceVertices = new List<IVertex>();
|
||||
foreach (FaceEdge faceEdgeToAdd in face.FaceEdges())
|
||||
{
|
||||
Vertex newVertex = discreteMeshes[areaIndex].CreateVertex(faceEdgeToAdd.firstVertex.Position);
|
||||
var newVertex = discreteMeshes[areaIndex].CreateVertex(faceEdgeToAdd.firstVertex.Position);
|
||||
faceVertices.Add(newVertex);
|
||||
}
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
reportProgress?.Invoke((.8, ""));
|
||||
reportProgress?.Invoke(.8, "");
|
||||
|
||||
for (int i = 0; i < discreteMeshes.Count(); i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
|
||||
/*
|
||||
public static void CreateITraceableForMeshGroup(List<PlatingMeshGroupData> perMeshGroupInfo, List<MeshGroup> meshGroups, int meshGroupIndex, ReportProgressRatio<(double ratio, string state)> reportProgress)
|
||||
public static void CreateITraceableForMeshGroup(List<PlatingMeshGroupData> perMeshGroupInfo, List<MeshGroup> meshGroups, int meshGroupIndex, Action<double, string> reportProgress)
|
||||
{
|
||||
if (meshGroups != null)
|
||||
{
|
||||
|
|
@ -366,7 +366,7 @@ namespace MatterHackers.MatterControl
|
|||
return BoundingVolumeHierarchy.CreateNewHierachy(allPolys);
|
||||
}
|
||||
|
||||
private static List<IPrimitive> AddTraceDataForMesh(Mesh mesh, int totalActionCount, ref int currentAction, ref bool needToUpdateProgressReport, ReportProgressRatio<(double ratio, string state)> reportProgress)
|
||||
private static List<IPrimitive> AddTraceDataForMesh(Mesh mesh, int totalActionCount, ref int currentAction, ref bool needToUpdateProgressReport, Action<double, string> reportProgress)
|
||||
{
|
||||
var continueProcessing = new CancellationTokenSource();
|
||||
|
||||
|
|
|
|||
|
|
@ -70,12 +70,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
public void ProgressReporter((double progress0To1, string processingState) progress)
|
||||
public void ProgressReporter(double progress0To1, string processingState)
|
||||
{
|
||||
progressBar.RatioComplete = progress.progress0To1;
|
||||
progressBar.RatioComplete = progress0To1;
|
||||
view3DWidget?.Invalidate();
|
||||
|
||||
if (progress.progress0To1 == 1)
|
||||
if (progress0To1 == 1)
|
||||
{
|
||||
if (view3DWidget != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,13 +32,10 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Threading;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.MatterControl;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
using MatterHackers.MeshVisualizer;
|
||||
using MatterHackers.PolygonMesh;
|
||||
using MatterHackers.RayTracer;
|
||||
|
|
|
|||
|
|
@ -27,29 +27,23 @@ 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.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.OpenGlGui;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
using MatterHackers.PolygonMesh;
|
||||
using MatterHackers.PolygonMesh.Processors;
|
||||
using MatterHackers.RayTracer;
|
||||
using MatterHackers.RayTracer.Traceable;
|
||||
using MatterHackers.RenderOpenGl;
|
||||
using MatterHackers.RenderOpenGl.OpenGl;
|
||||
using MatterHackers.VectorMath;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using System.Threading;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
|
||||
namespace MatterHackers.MeshVisualizer
|
||||
{
|
||||
|
|
@ -593,18 +587,18 @@ namespace MatterHackers.MeshVisualizer
|
|||
partProcessingInfo.Visible = false;
|
||||
}
|
||||
|
||||
public void ReportProgress0to100((double progress0To1, string processingState) progress)
|
||||
public void ReportProgress0to100(double progress0To1, string processingState)
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
int percentComplete = (int)(progress.progress0To1 * 100);
|
||||
int percentComplete = (int)(progress0To1 * 100);
|
||||
partProcessingInfo.centeredInfoText.Text = "{0} {1}%...".FormatWith(progressReportingPrimaryTask, percentComplete);
|
||||
partProcessingInfo.progressControl.PercentComplete = percentComplete;
|
||||
|
||||
// Only assign to textbox if value passed through
|
||||
if (progress.processingState != null)
|
||||
if (processingState != null)
|
||||
{
|
||||
partProcessingInfo.centeredInfoDescription.Text = progress.processingState;
|
||||
partProcessingInfo.centeredInfoDescription.Text = processingState;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ using System.Globalization;
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
|
|
@ -62,9 +61,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
&& !selectedItem.HasChildren
|
||||
&& selectedItem.Mesh != null)
|
||||
{
|
||||
var discreetMeshes = CreateDiscreteMeshes.SplitVolumesIntoMeshes(Scene.SelectedItem.Mesh, CancellationToken.None, ((double progress0To1, string processingState) progress) =>
|
||||
var discreetMeshes = CreateDiscreteMeshes.SplitVolumesIntoMeshes(Scene.SelectedItem.Mesh, CancellationToken.None, (double progress0To1, string processingState) =>
|
||||
{
|
||||
view3DWidget.ReportProgressChanged(progress.progress0To1 * .5, progress.processingState);
|
||||
view3DWidget.ReportProgressChanged(progress0To1 * .5, processingState);
|
||||
});
|
||||
|
||||
if (discreetMeshes.Count == 1)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ using MatterHackers.Agg.UI;
|
|||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.ActionBar;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.DataStorage;
|
||||
using MatterHackers.MatterControl.Library;
|
||||
|
|
@ -890,17 +889,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
sourceListItem.StartProgress();
|
||||
|
||||
contentResult = DragSourceModel.CreateContent(((double progress0To1, string processingState) progress) =>
|
||||
contentResult = DragSourceModel.CreateContent((double ratio, string state) =>
|
||||
{
|
||||
sourceListItem.ProgressReporter(progress);
|
||||
loadProgress.ProgressReporter(progress);
|
||||
sourceListItem.ProgressReporter(ratio, state);
|
||||
loadProgress.ProgressReporter(ratio, state);
|
||||
});
|
||||
|
||||
await contentResult.MeshLoaded;
|
||||
|
||||
sourceListItem.EndProgress();
|
||||
|
||||
loadProgress.ProgressReporter((1, ""));
|
||||
loadProgress.ProgressReporter(1, "");
|
||||
}
|
||||
|
||||
return contentResult?.Object3D;
|
||||
|
|
@ -1842,10 +1841,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
var libraryItem = new FileSystemFileItem(filePath);
|
||||
|
||||
var contentResult = libraryItem.CreateContent(((double progress0To1, string processingState) progress) =>
|
||||
var contentResult = libraryItem.CreateContent((double progress0To1, string processingState) =>
|
||||
{
|
||||
double ratioAvailable = (ratioPerFile * .5);
|
||||
double currentRatio = currentRatioDone + progress.progress0To1 * ratioAvailable;
|
||||
double currentRatio = currentRatioDone + progress0To1 * ratioAvailable;
|
||||
|
||||
ReportProgressChanged(currentRatio, progressMessage);
|
||||
});
|
||||
|
|
@ -1886,7 +1885,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
Matrix4X4 objectToWold = objectToLayFlatGroup.Matrix;
|
||||
IObject3D objectToLayFlat = objectToLayFlatGroup.Children[0];
|
||||
|
||||
Vertex lowestVertex = objectToLayFlat.Mesh.Vertices[0];
|
||||
var lowestVertex = objectToLayFlat.Mesh.Vertices[0];
|
||||
|
||||
Vector3 lowestVertexPosition = Vector3.Transform(lowestVertex.Position, objectToWold);
|
||||
|
||||
|
|
@ -1898,7 +1897,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
// find the lowest point on the model
|
||||
for (int testIndex = 1; testIndex < itemToCheck.Mesh.Vertices.Count; testIndex++)
|
||||
{
|
||||
Vertex vertex = itemToCheck.Mesh.Vertices[testIndex];
|
||||
var vertex = itemToCheck.Mesh.Vertices[testIndex];
|
||||
Vector3 vertexPosition = Vector3.Transform(vertex.Position, objectToWold);
|
||||
if (vertexPosition.z < lowestVertexPosition.z)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@ either expressed or implied, of the FreeBSD Project.
|
|||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.GCodeVisualizer;
|
||||
|
|
@ -174,9 +172,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
internal void LoadProgress_Changed((double progress0To1, string processingState) progress)
|
||||
internal void LoadProgress_Changed(double progress0To1, string processingState)
|
||||
{
|
||||
SetProcessingMessage(string.Format("{0} {1:0}%...", gcodeLoading, progress.progress0To1 * 100));
|
||||
SetProcessingMessage(string.Format("{0} {1:0}%...", gcodeLoading, progress0To1 * 100));
|
||||
}
|
||||
|
||||
private void SetProcessingMessage(string message)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 0df89d544f83e0359fb512a4b83e1fc91c23890e
|
||||
Subproject commit 0ae38f47898e67ca5d948fdfdf06877185caf159
|
||||
Loading…
Add table
Add a link
Reference in a new issue