diff --git a/MatterControl.MeshOperations/BooleanProcessing.cs b/MatterControl.MeshOperations/BooleanProcessing.cs index f613974aa..730cf967c 100644 --- a/MatterControl.MeshOperations/BooleanProcessing.cs +++ b/MatterControl.MeshOperations/BooleanProcessing.cs @@ -35,6 +35,7 @@ using System.Linq; using System.Runtime.InteropServices; using System.Threading; using g3; +using gs; using MatterHackers.Agg; using MatterHackers.MatterControl.DesignTools; using MatterHackers.PolygonMesh; @@ -156,10 +157,10 @@ namespace MatterHackers.PolygonMesh { var bounds = root.Bounds(); - var c = new MarchingCubes() + var c = new MarchingCubesPro() { Implicit = root, - RootMode = MarchingCubes.RootfindingModes.LerpSteps, // cube-edge convergence method + RootMode = MarchingCubesPro.RootfindingModes.LerpSteps, // cube-edge convergence method RootModeSteps = 5, // number of iterations Bounds = bounds, CubeSize = bounds.MaxDim / numCells, diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 4b3d159ed..e64825782 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -1788,7 +1788,7 @@ namespace MatterHackers.MatterControl leftChild.Padding = new BorderDouble(padding.Left, padding.Bottom, sourceExentionArea.Width, padding.Height); } - public async Task PrintPart(EditContext editContext, PrinterConfig printer, IProgress reporter, CancellationToken cancellationToken, bool recordPrintHistory) + public async Task PrintPart(EditContext editContext, PrinterConfig printer, IProgress reporter, CancellationToken cancellationToken, PrinterConnection.PrintingModes printingMode) { var partFilePath = editContext.SourceFilePath; var gcodeFilePath = await editContext.GCodeFilePath(printer); @@ -1859,7 +1859,7 @@ namespace MatterHackers.MatterControl if (messageBoxResponse) { printer.Connection.CommunicationState = CommunicationStates.PreparingToPrint; - this.ArchiveAndStartPrint(partFilePath, gcodeFilePath, printer, recordPrintHistory); + this.ArchiveAndStartPrint(partFilePath, gcodeFilePath, printer, printingMode); } }, "The file you are attempting to print is a GCode file.\n\nIt is recommended that you only print Gcode files known to match your printer's configuration.\n\nAre you sure you want to print this GCode file?".Localize(), @@ -1874,7 +1874,7 @@ namespace MatterHackers.MatterControl else { printer.Connection.CommunicationState = CommunicationStates.PreparingToPrint; - this.ArchiveAndStartPrint(partFilePath, gcodeFilePath, printer, recordPrintHistory); + this.ArchiveAndStartPrint(partFilePath, gcodeFilePath, printer, printingMode); } } else @@ -1889,7 +1889,7 @@ namespace MatterHackers.MatterControl // Only start print if slicing completed if (slicingSucceeded) { - this.ArchiveAndStartPrint(partFilePath, finalPath, printer, recordPrintHistory); + this.ArchiveAndStartPrint(partFilePath, finalPath, printer, printingMode); } else { @@ -2057,7 +2057,7 @@ namespace MatterHackers.MatterControl /// /// The source file which originally caused the slice->print operation /// The resulting GCode to print - private async void ArchiveAndStartPrint(string sourcePath, string gcodeFilePath, PrinterConfig printer, bool recordPrintHistory) + private async void ArchiveAndStartPrint(string sourcePath, string gcodeFilePath, PrinterConfig printer, PrinterConnection.PrintingModes printingMode) { if (File.Exists(sourcePath) && File.Exists(gcodeFilePath)) @@ -2088,7 +2088,7 @@ namespace MatterHackers.MatterControl if (originalIsGCode) { - await printer.Connection.StartPrint(gcodeFilePath, recordPrintHistory: recordPrintHistory); + await printer.Connection.StartPrint(gcodeFilePath, printingMode: printingMode); MonitorPrintTask(printer); @@ -2099,7 +2099,7 @@ namespace MatterHackers.MatterControl // Ask for slicer specific gcode validation if (printer.Settings.Slicer.ValidateFile(gcodeFilePath)) { - await printer.Connection.StartPrint(gcodeFilePath, recordPrintHistory: recordPrintHistory); + await printer.Connection.StartPrint(gcodeFilePath, printingMode: printingMode); MonitorPrintTask(printer); return; } @@ -2235,7 +2235,7 @@ namespace MatterHackers.MatterControl public void Connection_PrintFinished(object sender, string e) { if (sender is PrinterConnection printerConnection - && printerConnection.RecordPrintHistory) + && printerConnection.PrintingMode == PrinterConnection.PrintingModes.Normal) { var printTasks = PrintHistoryData.Instance.GetHistoryItems(10); var printHistoryEditor = new PrintHistoryEditor(((PrinterConnection)sender).Printer, AppContext.Theme, printerConnection.ActivePrintTask, printTasks); @@ -2249,7 +2249,7 @@ namespace MatterHackers.MatterControl public void Connection_PrintCanceled(object sender, EventArgs e) { if (sender is PrinterConnection printerConnection - && printerConnection.RecordPrintHistory) + && printerConnection.PrintingMode == PrinterConnection.PrintingModes.Normal) { var printTasks = PrintHistoryData.Instance.GetHistoryItems(10); var printHistoryEditor = new PrintHistoryEditor(((PrinterConnection)sender).Printer, AppContext.Theme, printerConnection.CanceledPrintTask, printTasks); diff --git a/MatterControlLib/ApplicationView/Config/BedConfig.cs b/MatterControlLib/ApplicationView/Config/BedConfig.cs index 57f844ed2..d967e1a0f 100644 --- a/MatterControlLib/ApplicationView/Config/BedConfig.cs +++ b/MatterControlLib/ApplicationView/Config/BedConfig.cs @@ -43,6 +43,7 @@ using MatterHackers.Localizations; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.Library; using MatterHackers.MatterControl.PartPreviewWindow; +using MatterHackers.MatterControl.PrinterCommunication; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.MeshVisualizer; using MatterHackers.PolygonMesh; @@ -316,7 +317,7 @@ namespace MatterHackers.MatterControl this.Printer, null, CancellationToken.None, - true); + PrinterConnection.PrintingModes.Normal); } public async Task StashAndPrint(IEnumerable selectedLibraryItems) @@ -337,7 +338,7 @@ namespace MatterHackers.MatterControl this.Printer, null, CancellationToken.None, - true); + PrinterConnection.PrintingModes.Normal); } private GCodeFile loadedGCode; diff --git a/MatterControlLib/CustomWidgets/XyCalibrationSelectPage.cs b/MatterControlLib/CustomWidgets/XyCalibrationSelectPage.cs index d27d3db7d..b97132012 100644 --- a/MatterControlLib/CustomWidgets/XyCalibrationSelectPage.cs +++ b/MatterControlLib/CustomWidgets/XyCalibrationSelectPage.cs @@ -243,7 +243,7 @@ namespace MatterHackers.MatterControl ContentStore = null // No content store for GCode }); - await printer.Connection.StartPrint(finalGCodePath, recordPrintHistory: false); + await printer.Connection.StartPrint(finalGCodePath, printingMode: PrinterConnection.PrintingModes.Calibration); ApplicationController.Instance.MonitorPrintTask(printer); } else diff --git a/MatterControlLib/DesignTools/Attributes/DisplayAsTime.cs b/MatterControlLib/DesignTools/Attributes/DisplayAsTime.cs new file mode 100644 index 000000000..4597a929d --- /dev/null +++ b/MatterControlLib/DesignTools/Attributes/DisplayAsTime.cs @@ -0,0 +1,38 @@ +/* +Copyright (c) 2018, Lars Brubaker, John Lewin +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. +*/ + +using System; + +namespace MatterHackers.MatterControl.DesignTools +{ + [AttributeUsage(AttributeTargets.Property)] + public class DisplayAsTimeAttribute : Attribute + { + } +} \ No newline at end of file diff --git a/MatterControlLib/DesignTools/PublicPropertyEditor.cs b/MatterControlLib/DesignTools/PublicPropertyEditor.cs index e29c6a81f..9cae6c98d 100644 --- a/MatterControlLib/DesignTools/PublicPropertyEditor.cs +++ b/MatterControlLib/DesignTools/PublicPropertyEditor.cs @@ -618,11 +618,26 @@ namespace MatterHackers.MatterControl.DesignTools { if (readOnly) { - var valueField = new TextWidget(string.Format("{0:n0}", intValue), + string FormateInt(int value) + { + if (property.PropertyInfo.GetCustomAttributes(true).OfType().FirstOrDefault() != null) + { + var minutes = intValue / 60; + var hours = minutes / 60; + return $"{hours:00}:{minutes % 60:00}:{intValue % 60:00}"; + } + else + { + return string.Format("{0:n0}", intValue); + } + } + + var valueField = new TextWidget(FormateInt(intValue), textColor: theme.TextColor, pointSize: 10) { - AutoExpandBoundsToText = true + AutoExpandBoundsToText = true, + Margin = new BorderDouble(0, 0, 7, 0), }; rowContainer = new SettingsRow(property.DisplayName.Localize(), @@ -635,7 +650,7 @@ namespace MatterHackers.MatterControl.DesignTools if (e.InvalidateType.HasFlag(InvalidateType.DisplayValues)) { int newValue = (int)property.Value; - valueField.Text = string.Format("{0:n0}", newValue); + valueField.Text = string.Format(FormateInt(intValue), newValue); } } @@ -773,7 +788,7 @@ namespace MatterHackers.MatterControl.DesignTools var wrapContainer = new GuiWidget() { - Margin = new BorderDouble(displayName.Width + displayName.Margin.Width + 15, 9, 9, 9), + Margin = new BorderDouble(displayName.Width + displayName.Margin.Width + 15, 3, 3, 3), HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit }; diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs index 4a88221e9..30147c0a2 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs @@ -40,6 +40,7 @@ using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.Library; using MatterHackers.MatterControl.Library.Export; using MatterHackers.MatterControl.Plugins.X3GDriver; +using MatterHackers.MatterControl.PrinterCommunication; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.VectorMath; @@ -348,7 +349,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow printer, null, CancellationToken.None, - true); + PrinterConnection.PrintingModes.Normal); }); }; diff --git a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs index d08f8e698..f3e8452f9 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs @@ -49,6 +49,7 @@ using MatterHackers.Localizations; using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.DesignTools; using MatterHackers.MatterControl.Library; +using MatterHackers.MatterControl.PrinterCommunication; using MatterHackers.MatterControl.PrinterControls.PrinterConnections; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.RayTracer; @@ -942,7 +943,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow printer, null, CancellationToken.None, - true).ConfigureAwait(false); + PrinterConnection.PrintingModes.Normal).ConfigureAwait(false); }); } else if (ProfileManager.Instance.ActiveProfiles.Count() <= 0) @@ -1053,7 +1054,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow printer, null, CancellationToken.None, - true); + PrinterConnection.PrintingModes.Normal); }); } diff --git a/MatterControlLib/PrinterCommunication/PrinterConnection.cs b/MatterControlLib/PrinterCommunication/PrinterConnection.cs index fb19a833e..af4bba800 100644 --- a/MatterControlLib/PrinterCommunication/PrinterConnection.cs +++ b/MatterControlLib/PrinterCommunication/PrinterConnection.cs @@ -2110,24 +2110,31 @@ Make sure that your printer is turned on. Some printers will appear to be connec } } - public bool RecordPrintHistory { get; private set; } + public PrintingModes PrintingMode { get; private set; } private CancellationTokenSource printingCancellation; - public async Task StartPrint(string gcodeFilename, PrintTask printTaskToUse = null, bool recordPrintHistory = true) + public enum PrintingModes { - var gcodeStream = new StreamReader(gcodeFilename); - await StartPrint(gcodeStream.BaseStream, gcodeFilename, printTaskToUse, recordPrintHistory); + Normal, + Calibration, + AutoPilot, } - public async Task StartPrint(Stream gcodeStream, string gcodeFileNameForTask, PrintTask printTaskToUse, bool recordPrintHistory) + public async Task StartPrint(string gcodeFilename, PrintTask printTaskToUse = null, PrintingModes printingMode = PrintingModes.Normal) + { + var gcodeStream = new StreamReader(gcodeFilename); + await StartPrint(gcodeStream.BaseStream, gcodeFilename, printTaskToUse, printingMode); + } + + public async Task StartPrint(Stream gcodeStream, string gcodeFileNameForTask, PrintTask printTaskToUse, PrintingModes printingMode) { if (!this.IsConnected || Printing) { return; } - this.RecordPrintHistory = recordPrintHistory; + this.PrintingMode = printingMode; printingCancellation = new CancellationTokenSource(); @@ -2170,7 +2177,7 @@ Make sure that your printer is turned on. Some printers will appear to be connec if (gcodeFileNameForTask != null && ActivePrintTask == null - && RecordPrintHistory) + && PrintingMode != PrintingModes.Calibration) { // TODO: Fix printerItemID int requirement ActivePrintTask = new PrintTask diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 503b73e80..22cfd2547 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 503b73e80b06db075a0b3572498c916ff816b77e +Subproject commit 22cfd2547fbffefc41b538488a4cad1a1a4bef06 diff --git a/Tests/MatterControl.Tests/MatterControl/ToolChangeTests.cs b/Tests/MatterControl.Tests/MatterControl/ToolChangeTests.cs index 748abd7f2..829151501 100644 --- a/Tests/MatterControl.Tests/MatterControl/ToolChangeTests.cs +++ b/Tests/MatterControl.Tests/MatterControl/ToolChangeTests.cs @@ -595,7 +595,7 @@ namespace MatterControl.Tests.MatterControl.ToolChanges // start a print printer.Connection.CommunicationState = CommunicationStates.PreparingToPrint; - await printer.Connection.StartPrint(inputStream, null, null, true); + await printer.Connection.StartPrint(inputStream, null, null, PrinterConnection.PrintingModes.Normal); // wait up to 40 seconds for the print to finish timer = Stopwatch.StartNew();