diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/LevelingFunctions.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/LevelingFunctions.cs index a104318ce..47c96135a 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/LevelingFunctions.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/LevelingFunctions.cs @@ -128,7 +128,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling double feedRate = 0; GCodeFile.GetFirstNumberAfter("F", lineBeingSent, ref feedRate); - StringBuilder newLine = new StringBuilder("G1 "); + var newLine = new StringBuilder("G1"); if (lineBeingSent.Contains("X") || lineBeingSent.Contains("Y") || lineBeingSent.Contains("Z")) { @@ -136,20 +136,20 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling lastDestinationWithLevelingApplied = outPosition; - newLine = newLine.Append($"X{outPosition.X:0.##} Y{outPosition.Y:0.##} Z{outPosition.Z:0.##} "); + newLine.Append($" X{outPosition.X:0.##} Y{outPosition.Y:0.##} Z{outPosition.Z:0.##}"); } if (lineBeingSent.Contains("E")) { - newLine = newLine.Append($"E{extruderDelta:0.###} "); + newLine.Append($" E{extruderDelta:0.###}"); } if (lineBeingSent.Contains("F")) { - newLine = newLine.Append($"F{feedRate:0.##}"); + newLine.Append($" F{feedRate:0.##}"); } - return newLine.ToString().Trim(); + return newLine.ToString(); } public Vector3 GetPositionWithZOffset(Vector3 currentDestination) diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPageInstructions.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPageInstructions.cs index b60c75f0f..9d6a870cc 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPageInstructions.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPageInstructions.cs @@ -39,8 +39,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { public class CalibrateProbeLastPageInstructions : WizardPage { - private bool pageWasActive = false; - public CalibrateProbeLastPageInstructions(ISetupWizard setupWizard, string headerText) : base(setupWizard, headerText, "") { @@ -66,23 +64,24 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { printer.Connection.QueueLine("T0"); printer.Connection.MoveRelative(PrinterConnection.Axis.X, .1, printer.Connection.CurrentFeedRate); + if (printer.Settings.GetValue(SettingsKey.z_homes_to_max)) { printer.Connection.HomeAxis(PrinterConnection.Axis.XYZ); } - - pageWasActive = true; + else if (!printer.Settings.GetValue(SettingsKey.has_z_probe)) + { + // Lift the hotend off the bed - at the conclusion of the wizard, make sure we lift the heated nozzle off the bed + printer.Connection.MoveRelative(PrinterConnection.Axis.Z, 2, printer.Settings.Helpers.ManualMovementSpeeds().Z); + } base.OnLoad(args); } public override void OnClosed(EventArgs e) { - if (pageWasActive) - { - // move from this wizard to the print leveling wizard if needed - ApplicationController.Instance.RunAnyRequiredPrinterSetup(printer, theme); - } + // move from this wizard to the print leveling wizard if needed + ApplicationController.Instance.RunAnyRequiredPrinterSetup(printer, theme); } } } \ No newline at end of file diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/LastPageInstructions.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/LastPageInstructions.cs index 81936cc2f..cf08f16d0 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/LastPageInstructions.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/LastPageInstructions.cs @@ -97,14 +97,21 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { printer.Connection.HomeAxis(PrinterConnection.Axis.XYZ); } - - Closed += (s, e) => + else if (!printer.Settings.GetValue(SettingsKey.has_z_probe)) { - // give instruction about how to load filament if the user has not gotten them - ApplicationController.Instance.RunAnyRequiredPrinterSetup(printer, theme); - }; + // Lift the hotend off the bed - at the conclusion of the wizard, make sure we lift the heated nozzle off the bed + printer.Connection.MoveRelative(PrinterConnection.Axis.Z, 2, printer.Settings.Helpers.ManualMovementSpeeds().Z); + } base.OnLoad(args); } + + public override void OnClosed(EventArgs e) + { + // give instruction about how to load filament if the user has not gotten them + ApplicationController.Instance.RunAnyRequiredPrinterSetup(printer, theme); + + base.OnClosed(e); + } } } \ No newline at end of file diff --git a/MatterControlLib/DesignTools/Braille/BrailleCardObject3D.cs b/MatterControlLib/DesignTools/Braille/BrailleCardObject3D.cs index 5f39d3fde..0b1300200 100644 --- a/MatterControlLib/DesignTools/Braille/BrailleCardObject3D.cs +++ b/MatterControlLib/DesignTools/Braille/BrailleCardObject3D.cs @@ -131,7 +131,7 @@ namespace MatterHackers.MatterControl.DesignTools } } - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); } } } \ No newline at end of file diff --git a/MatterControlLib/DesignTools/Braille/BrailleObject3D.cs b/MatterControlLib/DesignTools/Braille/BrailleObject3D.cs index 87c1a7a00..51240f769 100644 --- a/MatterControlLib/DesignTools/Braille/BrailleObject3D.cs +++ b/MatterControlLib/DesignTools/Braille/BrailleObject3D.cs @@ -261,7 +261,7 @@ namespace MatterHackers.MatterControl.DesignTools } } - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; } } diff --git a/MatterControlLib/DesignTools/LithophaneObject3D.cs b/MatterControlLib/DesignTools/LithophaneObject3D.cs index 9bf088b75..8ef259acd 100644 --- a/MatterControlLib/DesignTools/LithophaneObject3D.cs +++ b/MatterControlLib/DesignTools/LithophaneObject3D.cs @@ -65,7 +65,7 @@ namespace MatterHackers.MatterControl.Plugins.Lithophane public Vector3 ImageOffset { get; private set; } = Vector3.Zero; - public override void OnInvalidate(InvalidateArgs invalidateArgs) + public override async void OnInvalidate(InvalidateArgs invalidateArgs) { var invalidateType = invalidateArgs.InvalidateType; if ((invalidateType.HasFlag(InvalidateType.Children) @@ -74,12 +74,12 @@ namespace MatterHackers.MatterControl.Plugins.Lithophane && invalidateArgs.Source != this && !RebuildLocked) { - Rebuild(); + await Rebuild(); } else if (invalidateArgs.InvalidateType.HasFlag(InvalidateType.Properties) && invalidateArgs.Source == this) { - Rebuild(); + await Rebuild(); } else { @@ -114,7 +114,7 @@ namespace MatterHackers.MatterControl.Plugins.Lithophane // Apply offset this.Matrix *= Matrix4X4.CreateTranslation(-this.ImageOffset); - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; }); diff --git a/MatterControlLib/DesignTools/Obsolete/CombineObject3D.cs b/MatterControlLib/DesignTools/Obsolete/CombineObject3D.cs index b099547f0..7c7240cf0 100644 --- a/MatterControlLib/DesignTools/Obsolete/CombineObject3D.cs +++ b/MatterControlLib/DesignTools/Obsolete/CombineObject3D.cs @@ -96,7 +96,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } rebuildLocks.Dispose(); - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; }); } diff --git a/MatterControlLib/DesignTools/Obsolete/CurveObject3D.cs b/MatterControlLib/DesignTools/Obsolete/CurveObject3D.cs index f08d97668..fe28ae30c 100644 --- a/MatterControlLib/DesignTools/Obsolete/CurveObject3D.cs +++ b/MatterControlLib/DesignTools/Obsolete/CurveObject3D.cs @@ -274,7 +274,7 @@ namespace MatterHackers.MatterControl.DesignTools Matrix = currentMatrix; } - Invalidate(InvalidateType.Mesh); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); if (valuesChanged) { Invalidate(InvalidateType.DisplayValues); diff --git a/MatterControlLib/DesignTools/Obsolete/FitToBoundsObject3D.cs b/MatterControlLib/DesignTools/Obsolete/FitToBoundsObject3D.cs index 8b0a6896c..226432281 100644 --- a/MatterControlLib/DesignTools/Obsolete/FitToBoundsObject3D.cs +++ b/MatterControlLib/DesignTools/Obsolete/FitToBoundsObject3D.cs @@ -103,7 +103,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations list.AddRange(ScaleItem.Children); }); } - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); } public override void Remove(UndoBuffer undoBuffer) @@ -124,7 +124,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations }); } - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); } public override void OnInvalidate(InvalidateArgs invalidateType) @@ -178,7 +178,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } } - Invalidate(InvalidateType.Matrix); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix)); return Task.CompletedTask; } diff --git a/MatterControlLib/DesignTools/Obsolete/IntersectionObject3D.cs b/MatterControlLib/DesignTools/Obsolete/IntersectionObject3D.cs index 6e1b47196..4c99960b1 100644 --- a/MatterControlLib/DesignTools/Obsolete/IntersectionObject3D.cs +++ b/MatterControlLib/DesignTools/Obsolete/IntersectionObject3D.cs @@ -90,7 +90,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } rebuildLocks.Dispose(); - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; }); } diff --git a/MatterControlLib/DesignTools/Obsolete/MirrorObject3D.cs b/MatterControlLib/DesignTools/Obsolete/MirrorObject3D.cs index 9b07f3beb..260d3cc9f 100644 --- a/MatterControlLib/DesignTools/Obsolete/MirrorObject3D.cs +++ b/MatterControlLib/DesignTools/Obsolete/MirrorObject3D.cs @@ -93,12 +93,12 @@ namespace MatterHackers.MatterControl.DesignTools this.Matrix = oldMatrix; } - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; } - public override void OnInvalidate(InvalidateArgs invalidateType) + public override async void OnInvalidate(InvalidateArgs invalidateType) { if ((invalidateType.InvalidateType.HasFlag(InvalidateType.Children) || invalidateType.InvalidateType.HasFlag(InvalidateType.Matrix) @@ -106,12 +106,12 @@ namespace MatterHackers.MatterControl.DesignTools && invalidateType.Source != this && !RebuildLocked) { - Rebuild(); + await Rebuild(); } else if (invalidateType.InvalidateType.HasFlag(InvalidateType.Properties) && invalidateType.Source == this) { - Rebuild(); + await Rebuild(); } else { diff --git a/MatterControlLib/DesignTools/Obsolete/PinchObject3D.cs b/MatterControlLib/DesignTools/Obsolete/PinchObject3D.cs index 0711a750c..5f3ad6dc8 100644 --- a/MatterControlLib/DesignTools/Obsolete/PinchObject3D.cs +++ b/MatterControlLib/DesignTools/Obsolete/PinchObject3D.cs @@ -56,7 +56,7 @@ namespace MatterHackers.MatterControl.DesignTools [DisplayName("Back Ratio")] public double PinchRatio { get; set; } = .5; - public override void OnInvalidate(InvalidateArgs invalidateType) + public override async void OnInvalidate(InvalidateArgs invalidateType) { if ((invalidateType.InvalidateType.HasFlag(InvalidateType.Children) || invalidateType.InvalidateType.HasFlag(InvalidateType.Matrix) @@ -64,12 +64,12 @@ namespace MatterHackers.MatterControl.DesignTools && invalidateType.Source != this && !RebuildLocked) { - Rebuild(); + await Rebuild(); } else if (invalidateType.InvalidateType.HasFlag(InvalidateType.Properties) && invalidateType.Source == this) { - Rebuild(); + await Rebuild(); } else { @@ -125,7 +125,7 @@ namespace MatterHackers.MatterControl.DesignTools Matrix = currentMatrix; } - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; } } diff --git a/MatterControlLib/DesignTools/Obsolete/RotateObject3D.cs b/MatterControlLib/DesignTools/Obsolete/RotateObject3D.cs index 2272e3ed7..9facf8ed9 100644 --- a/MatterControlLib/DesignTools/Obsolete/RotateObject3D.cs +++ b/MatterControlLib/DesignTools/Obsolete/RotateObject3D.cs @@ -93,7 +93,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } } - Invalidate(InvalidateType.Matrix); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix)); return Task.CompletedTask; } diff --git a/MatterControlLib/DesignTools/Operations/AlignObject3D.cs b/MatterControlLib/DesignTools/Operations/AlignObject3D.cs index 503845051..91f963ef7 100644 --- a/MatterControlLib/DesignTools/Operations/AlignObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/AlignObject3D.cs @@ -420,7 +420,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations })); } - Invalidate(InvalidateType.Matrix); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix)); return Task.CompletedTask; } diff --git a/MatterControlLib/DesignTools/Operations/ArrayAdvancedObject3D.cs b/MatterControlLib/DesignTools/Operations/ArrayAdvancedObject3D.cs index b5350f619..0ddb45c88 100644 --- a/MatterControlLib/DesignTools/Operations/ArrayAdvancedObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/ArrayAdvancedObject3D.cs @@ -100,7 +100,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations }); SourceContainer.Visible = false; rebuildLock.Dispose(); - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; }); } diff --git a/MatterControlLib/DesignTools/Operations/ArrayLinearObject3D.cs b/MatterControlLib/DesignTools/Operations/ArrayLinearObject3D.cs index d196c00e9..b405c3977 100644 --- a/MatterControlLib/DesignTools/Operations/ArrayLinearObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/ArrayLinearObject3D.cs @@ -86,7 +86,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } SourceContainer.Visible = false; rebuildLock.Dispose(); - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; }); } diff --git a/MatterControlLib/DesignTools/Operations/ArrayRadialObject3D.cs b/MatterControlLib/DesignTools/Operations/ArrayRadialObject3D.cs index 24fe4f705..d6660cf60 100644 --- a/MatterControlLib/DesignTools/Operations/ArrayRadialObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/ArrayRadialObject3D.cs @@ -128,7 +128,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations }); SourceContainer.Visible = false; rebuildLock.Dispose(); - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; }); } diff --git a/MatterControlLib/DesignTools/Operations/CurveObject3D_2.cs b/MatterControlLib/DesignTools/Operations/CurveObject3D_2.cs index 64076f6ae..38bf0ea5d 100644 --- a/MatterControlLib/DesignTools/Operations/CurveObject3D_2.cs +++ b/MatterControlLib/DesignTools/Operations/CurveObject3D_2.cs @@ -185,7 +185,7 @@ namespace MatterHackers.MatterControl.DesignTools SourceContainer.Visible = false; rebuildLocks.Dispose(); } - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); } return Task.CompletedTask; diff --git a/MatterControlLib/DesignTools/Operations/FitToBoundsObject3D_2.cs b/MatterControlLib/DesignTools/Operations/FitToBoundsObject3D_2.cs index 1f8c63c0a..78818943a 100644 --- a/MatterControlLib/DesignTools/Operations/FitToBoundsObject3D_2.cs +++ b/MatterControlLib/DesignTools/Operations/FitToBoundsObject3D_2.cs @@ -233,7 +233,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } } - Invalidate(InvalidateType.Matrix); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix)); return Task.CompletedTask; } diff --git a/MatterControlLib/DesignTools/Operations/FitToCylinderObject3D.cs b/MatterControlLib/DesignTools/Operations/FitToCylinderObject3D.cs index 231b1f61f..35df9bd7e 100644 --- a/MatterControlLib/DesignTools/Operations/FitToCylinderObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/FitToCylinderObject3D.cs @@ -191,7 +191,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } } - Invalidate(InvalidateType.Matrix); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix)); return Task.CompletedTask; } diff --git a/MatterControlLib/DesignTools/Operations/Image/LinearExtrudeObject3D.cs b/MatterControlLib/DesignTools/Operations/Image/LinearExtrudeObject3D.cs index 1e1860070..a1eff68c3 100644 --- a/MatterControlLib/DesignTools/Operations/Image/LinearExtrudeObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Image/LinearExtrudeObject3D.cs @@ -127,7 +127,7 @@ namespace MatterHackers.MatterControl.DesignTools } rebuildLock.Dispose(); - Invalidate(InvalidateType.Mesh); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); return Task.CompletedTask; }); } diff --git a/MatterControlLib/DesignTools/Operations/MirrorObject3D_2.cs b/MatterControlLib/DesignTools/Operations/MirrorObject3D_2.cs index 8f1b5d81e..d29d1078c 100644 --- a/MatterControlLib/DesignTools/Operations/MirrorObject3D_2.cs +++ b/MatterControlLib/DesignTools/Operations/MirrorObject3D_2.cs @@ -106,7 +106,7 @@ namespace MatterHackers.MatterControl.DesignTools this.Matrix = oldMatrix; SourceContainer.Visible = false; rebuildLock.Dispose(); - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; }); } diff --git a/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs index 1d0c03459..76e14a070 100644 --- a/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs @@ -32,7 +32,6 @@ using ClipperLib; using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; -using MatterHackers.MatterControl.DesignTools.Operations; namespace MatterHackers.MatterControl.DesignTools.Operations { @@ -58,7 +57,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations [Description("Change the width of the image lines.")] public double Inflate { get; set; } - public override void OnInvalidate(InvalidateArgs invalidateType) + public override async void OnInvalidate(InvalidateArgs invalidateType) { if ((invalidateType.InvalidateType.HasFlag(InvalidateType.Children) || invalidateType.InvalidateType.HasFlag(InvalidateType.Matrix) @@ -66,12 +65,12 @@ namespace MatterHackers.MatterControl.DesignTools.Operations && invalidateType.Source != this && !RebuildLocked) { - Rebuild(); + await Rebuild(); } else if (invalidateType.InvalidateType.HasFlag(InvalidateType.Properties) && invalidateType.Source == this) { - Rebuild(); + await Rebuild(); } else { @@ -87,7 +86,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations InsetPath(); } - Invalidate(InvalidateType.Path); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path)); return Task.CompletedTask; } diff --git a/MatterControlLib/DesignTools/Operations/Path/SmoothPathObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/SmoothPathObject3D.cs index 548571f82..57e625d4b 100644 --- a/MatterControlLib/DesignTools/Operations/Path/SmoothPathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/SmoothPathObject3D.cs @@ -92,7 +92,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations DoSmoothing((long)(SmoothDistance * 1000), Iterations); rebuildLock.Dispose(); - Invalidate(InvalidateType.Path); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path)); return Task.CompletedTask; }); } diff --git a/MatterControlLib/DesignTools/Operations/RotateObject3D_2.cs b/MatterControlLib/DesignTools/Operations/RotateObject3D_2.cs index 010934e78..8b5e7669a 100644 --- a/MatterControlLib/DesignTools/Operations/RotateObject3D_2.cs +++ b/MatterControlLib/DesignTools/Operations/RotateObject3D_2.cs @@ -137,7 +137,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations ItemWithTransform.Matrix = RotationMatrix; } - Invalidate(InvalidateType.Matrix); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix)); return Task.CompletedTask; } diff --git a/MatterControlLib/DesignTools/Operations/ScaleObject3D.cs b/MatterControlLib/DesignTools/Operations/ScaleObject3D.cs index 459e32840..14c59bac5 100644 --- a/MatterControlLib/DesignTools/Operations/ScaleObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/ScaleObject3D.cs @@ -218,7 +218,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations ItemWithTransform.Matrix *= Matrix4X4.CreateTranslation(ScaleAbout); } - Invalidate(InvalidateType.Matrix); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix)); return Task.CompletedTask; } diff --git a/MatterControlLib/DesignTools/Operations/TranslateObject3D.cs b/MatterControlLib/DesignTools/Operations/TranslateObject3D.cs index 57f2f8dfd..91ae3954a 100644 --- a/MatterControlLib/DesignTools/Operations/TranslateObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/TranslateObject3D.cs @@ -76,7 +76,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations #endregion // editable properties - public override void OnInvalidate(InvalidateArgs invalidateType) + public override async void OnInvalidate(InvalidateArgs invalidateType) { if ((invalidateType.InvalidateType.HasFlag(InvalidateType.Children) || invalidateType.InvalidateType.HasFlag(InvalidateType.Matrix) @@ -84,12 +84,12 @@ namespace MatterHackers.MatterControl.DesignTools.Operations && invalidateType.Source != this && !RebuildLocked) { - Rebuild(); + await Rebuild(); } else if (invalidateType.InvalidateType.HasFlag(InvalidateType.Properties) && invalidateType.Source == this) { - Rebuild(); + await Rebuild(); } else { @@ -107,7 +107,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations ItemWithTransform.Matrix = Matrix4X4.CreateTranslation(Translation); } - Invalidate(InvalidateType.Matrix); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix)); return Task.CompletedTask; } } diff --git a/MatterControlLib/DesignTools/Primitives/ImageObject3D.cs b/MatterControlLib/DesignTools/Primitives/ImageObject3D.cs index 8881a90ed..0b37280cc 100644 --- a/MatterControlLib/DesignTools/Primitives/ImageObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/ImageObject3D.cs @@ -101,7 +101,7 @@ namespace MatterHackers.MatterControl.DesignTools } // send the invalidate on image change - Invalidate(InvalidateType.Image); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Image)); } return _image; diff --git a/MatterControlLib/Library/Export/GCodeExport.cs b/MatterControlLib/Library/Export/GCodeExport.cs index 476ae6c21..94a33381a 100644 --- a/MatterControlLib/Library/Export/GCodeExport.cs +++ b/MatterControlLib/Library/Export/GCodeExport.cs @@ -287,6 +287,11 @@ namespace MatterHackers.MatterControl.Library.Export var queueStream = new QueuedCommandsStream(printer, gCodeBaseStream); GCodeStream accumulatedStream = queueStream; + if (printer.Settings.GetValue(SettingsKey.extruder_count) > 1) + { + accumulatedStream = new ToolChangeStream(printer, accumulatedStream); + } + accumulatedStream = new RelativeToAbsoluteStream(printer, accumulatedStream); bool levelingEnabled = printer.Settings.GetValue(SettingsKey.print_leveling_enabled) && applyLeveling; diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs index cdaaf0ead..f32e7d8ff 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs @@ -69,7 +69,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } rebuildLocks.Dispose(); - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; }); } diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/IntersectionObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/IntersectionObject3D_2.cs index ffadcfe6e..540837415 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/IntersectionObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/IntersectionObject3D_2.cs @@ -70,7 +70,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } rebuildLocks.Dispose(); - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; }); } diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D.cs index 022b561cf..013e78bb6 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D.cs @@ -178,7 +178,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } rebuildLocks.Dispose(); - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; }); } diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D_2.cs index 60308ef85..1b64e0e78 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractAndReplaceObject3D_2.cs @@ -131,7 +131,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } rebuildLocks.Dispose(); - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; }); } diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D.cs index a07af4a2d..25feb4d2e 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D.cs @@ -99,7 +99,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } rebuildLocks.Dispose(); - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; }); } diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs index 4013da36f..bae5af5dc 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractObject3D_2.cs @@ -137,7 +137,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } rebuildLocks.Dispose(); - Invalidate(InvalidateType.Children); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return Task.CompletedTask; }); } diff --git a/MatterControlLib/PrinterCommunication/Io/QueuedCommandsStream.cs b/MatterControlLib/PrinterCommunication/Io/QueuedCommandsStream.cs index 58314bfaf..ea44e8503 100644 --- a/MatterControlLib/PrinterCommunication/Io/QueuedCommandsStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/QueuedCommandsStream.cs @@ -27,18 +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.Diagnostics; using System.IO; -using System.Text.RegularExpressions; -using System.Threading; -using MatterControl.Printing; using MatterHackers.Agg.Image; using MatterHackers.Agg.Platform; -using MatterHackers.Agg.UI; -using MatterHackers.MatterControl.PrinterControls; -using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl.PrinterCommunication.Io { @@ -46,15 +38,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io { private List commandQueue = new List(); private object locker = new object(); - private int requestedExtruder; - private int extruderLastSwitchedTo; PrinterMove lastDestination = PrinterMove.Unknown; - int extruderCount = 0; public QueuedCommandsStream(PrinterConfig printer, GCodeStream internalStream) : base(printer, internalStream) { - extruderCount = printer.Settings.GetValue(SettingsKey.extruder_count); } public int Count => commandQueue.Count; @@ -70,68 +58,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io } else { - // If we are not printing, check if we need to switch extruders - if (extruderCount > 1 - && !printer.Connection.Printing) - { - CheckIfNeedToSwitchExtruders(line); - } - commandQueue.Add(line); } } } - private void CheckIfNeedToSwitchExtruders(string lineIn) - { - if(lineIn == null) - { - return; - } - - var lineNoComment = lineIn.Split(';')[0]; - - TrackExtruderState(lineNoComment); - - if ((lineNoComment.StartsWith("G0 ") || lineNoComment.StartsWith("G1 ")) // is a G1 or G0 - && (lineNoComment.Contains("X") || lineNoComment.Contains("Y") || lineNoComment.Contains("Z")) // hase a move axis in it - && extruderLastSwitchedTo != requestedExtruder) // is different than the last extruder set - { - string gcodeToQueue = ""; - switch (requestedExtruder) - { - case 0: - gcodeToQueue = printer.Settings.GetValue(SettingsKey.before_toolchange_gcode).Replace("\\n", "\n"); - break; - case 1: - gcodeToQueue = printer.Settings.GetValue(SettingsKey.before_toolchange_gcode_1).Replace("\\n", "\n"); - break; - } - - if (gcodeToQueue.Trim().Length > 0) - { - if (gcodeToQueue.Contains("\n")) - { - string[] linesToWrite = gcodeToQueue.Split(new string[] { "\n" }, StringSplitOptions.None); - for (int i = 0; i < linesToWrite.Length; i++) - { - string gcodeLine = linesToWrite[i].Trim(); - if (gcodeLine.Length > 0) - { - commandQueue.Add(gcodeLine); - } - } - } - else - { - commandQueue.Add(gcodeToQueue); - } - } - - extruderLastSwitchedTo = requestedExtruder; - } - } - public void Cancel() { Reset(); @@ -187,30 +118,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io lineToSend = base.ReadLine(); } - TrackExtruderState(lineToSend); - return lineToSend; } - private void TrackExtruderState(string line) - { - if (line == null) - { - return; - } - - if (line.StartsWith("G28)")) - { - extruderLastSwitchedTo = 0; - requestedExtruder = 0; - } - - if (line.StartsWith("T")) - { - GCodeFile.GetFirstNumberAfter("T", line, ref requestedExtruder); - } - } - public void Reset() { lock (locker) diff --git a/MatterControlLib/PrinterCommunication/Io/SoftwareEndstopsStream.cs b/MatterControlLib/PrinterCommunication/Io/SoftwareEndstopsStream.cs new file mode 100644 index 000000000..b2ed793a2 --- /dev/null +++ b/MatterControlLib/PrinterCommunication/Io/SoftwareEndstopsStream.cs @@ -0,0 +1,148 @@ +/* +Copyright (c) 2014, Lars Brubaker +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 MatterHackers.Agg; +using MatterHackers.MatterControl.SlicerConfiguration; +using MatterHackers.VectorMath; + +namespace MatterHackers.MatterControl.PrinterCommunication.Io +{ + public class SoftwareEndstopsStream : GCodeStreamProxy + { + private PrinterMove lastDestination = PrinterMove.Unknown; + + AxisAlignedBoundingBox[] extruderBounds = new AxisAlignedBoundingBox[4]; + + public SoftwareEndstopsStream(PrinterConfig printer, GCodeStream internalStream) + : base(printer, internalStream) + { + CalculateBounds(); + + printer.Settings.SettingChanged += Settings_SettingChanged; + + // Register to listen for position after home and update Bounds based on the axis homed and position info. + } + + private void Settings_SettingChanged(object sender, StringEventArgs stringEvent) + { + if (stringEvent.Data == SettingsKey.bed_size + || stringEvent.Data == SettingsKey.print_center + || stringEvent.Data == SettingsKey.build_height + || stringEvent.Data == SettingsKey.bed_shape) + { + this.CalculateBounds(); + } + } + + public override void Dispose() + { + printer.Settings.SettingChanged -= Settings_SettingChanged; + + base.Dispose(); + } + + private void CalculateBounds() + { + var bedSize = printer.Settings.GetValue(SettingsKey.bed_size); + var printCenter = printer.Settings.GetValue(SettingsKey.print_center); + var buildHeight = printer.Settings.GetValue(SettingsKey.build_height); + if (buildHeight == 0) + { + buildHeight = double.PositiveInfinity; + } + + // first set all the extruders to the bounds defined by the settings file + for (int i = 0; i < extruderBounds.Length; i++) + { + extruderBounds[i] = new AxisAlignedBoundingBox( + printCenter.X - bedSize.X / 2, // min x + printCenter.Y - bedSize.Y / 2, // min y + 0, // min z + printCenter.X + bedSize.X / 2, // max x + printCenter.Y + bedSize.Y / 2, // max y + buildHeight); // max z + + } + + // if we have more constrained info for extruders, add that it + + // If we know something about the homing positions, add them in. + // Specifically never go above a z homes max endstop. + // We may also want to add in all other know (measured) endstop postions. + + } + + public override string ReadLine() + { + string lineToSend = base.ReadLine(); + + if (lineToSend != null + && lineToSend.EndsWith("; NO_PROCESSING")) + { + return lineToSend; + } + + if (lineToSend != null + && LineIsMovement(lineToSend)) + { + PrinterMove currentMove = GetPosition(lineToSend, lastDestination); + + PrinterMove moveToSend = currentMove; + + if (moveToSend.HaveAnyPosition) + { + ClampToPrinter(ref moveToSend); + lineToSend = CreateMovementLine(moveToSend, lastDestination); + } + lastDestination = currentMove; + + return lineToSend; + } + + return lineToSend; + } + + public override void SetPrinterPosition(PrinterMove position) + { + this.lastDestination.CopyKnowSettings(position); + internalStream.SetPrinterPosition(lastDestination); + } + + private void ClampToPrinter(ref PrinterMove moveToSend) + { + var bounds = extruderBounds[printer.Connection.ActiveExtruderIndex]; + if (moveToSend.position.X < bounds.MinXYZ.X) + { + moveToSend.position.X = bounds.MinXYZ.X; + // If we clamp, than do not do any extrusion at all + moveToSend.extrusion = 0; + } + } + } +} \ No newline at end of file diff --git a/MatterControlLib/PrinterCommunication/Io/ToolChangeStream.cs b/MatterControlLib/PrinterCommunication/Io/ToolChangeStream.cs new file mode 100644 index 000000000..9eb22c638 --- /dev/null +++ b/MatterControlLib/PrinterCommunication/Io/ToolChangeStream.cs @@ -0,0 +1,156 @@ +/* +Copyright (c) 2019, 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; +using System.Collections.Generic; +using MatterControl.Printing; +using MatterHackers.MatterControl.SlicerConfiguration; + +namespace MatterHackers.MatterControl.PrinterCommunication.Io +{ + public class ToolChangeStream : GCodeStreamProxy + { + private Queue commandQueue = new Queue(); + private object locker = new object(); + private int requestedExtruder; + private int extruderLastSwitchedTo; + PrinterMove lastDestination = PrinterMove.Unknown; + int extruderCount = 0; + + public ToolChangeStream(PrinterConfig printer, GCodeStream internalStream) + : base(printer, internalStream) + { + extruderCount = printer.Settings.GetValue(SettingsKey.extruder_count); + } + + private bool CheckIfNeedToSwitchExtruders(string lineIn) + { + bool queuedSwitch = false; + if (lineIn == null) + { + return queuedSwitch; + } + + var lineNoComment = lineIn.Split(';')[0]; + + TrackExtruderState(lineNoComment); + + if ((lineNoComment.StartsWith("G0 ") || lineNoComment.StartsWith("G1 ")) // is a G1 or G0 + && (lineNoComment.Contains("X") || lineNoComment.Contains("Y") || lineNoComment.Contains("Z")) // hase a move axis in it + && extruderLastSwitchedTo != requestedExtruder) // is different than the last extruder set + { + string gcodeToQueue = ""; + switch (requestedExtruder) + { + case 0: + gcodeToQueue = printer.Settings.GetValue(SettingsKey.before_toolchange_gcode).Replace("\\n", "\n"); + break; + case 1: + gcodeToQueue = printer.Settings.GetValue(SettingsKey.before_toolchange_gcode_1).Replace("\\n", "\n"); + break; + } + + if (gcodeToQueue.Trim().Length > 0) + { + if (gcodeToQueue.Contains("\n")) + { + string[] linesToWrite = gcodeToQueue.Split(new string[] { "\n" }, StringSplitOptions.None); + for (int i = 0; i < linesToWrite.Length; i++) + { + string gcodeLine = linesToWrite[i].Trim(); + if (gcodeLine.Length > 0) + { + commandQueue.Enqueue(gcodeLine); + } + } + } + else + { + commandQueue.Enqueue(gcodeToQueue); + } + + commandQueue.Enqueue(lineIn); + queuedSwitch = true; + } + + extruderLastSwitchedTo = requestedExtruder; + } + + return queuedSwitch; + } + + public override string ReadLine() + { + string lineToSend = null; + + // lock queue + lock (locker) + { + if (commandQueue.Count > 0) + { + lineToSend = commandQueue.Dequeue(); + lineToSend = printer.ReplaceMacroValues(lineToSend); + } + } + + if (lineToSend == null) + { + lineToSend = base.ReadLine(); + } + + if(CheckIfNeedToSwitchExtruders(lineToSend)) + { + return ""; + } + + TrackExtruderState(lineToSend); + + return lineToSend; + } + + private void TrackExtruderState(string line) + { + if (line == null) + { + return; + } + + if (line.StartsWith("G28)")) + { + extruderLastSwitchedTo = 0; + requestedExtruder = 0; + } + + if (line.StartsWith("T")) + { + GCodeFile.GetFirstNumberAfter("T", line, ref requestedExtruder); + } + } + } +} \ No newline at end of file diff --git a/MatterControlLib/PrinterCommunication/PrinterConnection.cs b/MatterControlLib/PrinterCommunication/PrinterConnection.cs index b25027e7a..9ce2571e7 100644 --- a/MatterControlLib/PrinterCommunication/PrinterConnection.cs +++ b/MatterControlLib/PrinterCommunication/PrinterConnection.cs @@ -195,6 +195,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication private FeedRateMultiplyerStream feedrateMultiplyerStream9 = null; private RequestTemperaturesStream requestTemperaturesStream10 = null; private ProcessWriteRegexStream processWriteRegExStream11 = null; + //private SoftwareEndstopsStream softwareEndstopsExStream12 = null; private GCodeStream totalGCodeStream = null; @@ -2132,7 +2133,15 @@ You will then need to logout and log back in to the computer for the changes to } queuedCommandStream3 = new QueuedCommandsStream(Printer, firstStreamToRead); - relativeToAbsoluteStream4 = new RelativeToAbsoluteStream(Printer, queuedCommandStream3); + if (ExtruderCount > 1) + { + var switchExtruderStream = new ToolChangeStream(Printer, queuedCommandStream3); + relativeToAbsoluteStream4 = new RelativeToAbsoluteStream(Printer, switchExtruderStream); + } + else + { + relativeToAbsoluteStream4 = new RelativeToAbsoluteStream(Printer, queuedCommandStream3); + } bool enableLineSpliting = gcodeFilename != null && Printer.Settings.GetValue(SettingsKey.enable_line_splitting); babyStepsStream5 = new BabyStepsStream(Printer, relativeToAbsoluteStream4, enableLineSpliting ? 1 : 2000); printLevelingStream6 = new PrintLevelingStream(Printer, babyStepsStream5, true); @@ -2141,7 +2150,13 @@ You will then need to logout and log back in to the computer for the changes to feedrateMultiplyerStream9 = new FeedRateMultiplyerStream(Printer, extrusionMultiplyerStream8); requestTemperaturesStream10 = new RequestTemperaturesStream(Printer, feedrateMultiplyerStream9); processWriteRegExStream11 = new ProcessWriteRegexStream(Printer, requestTemperaturesStream10, queuedCommandStream3); + +#if true totalGCodeStream = processWriteRegExStream11; +#else + softwareEndstopsExStream12 = new SoftwareEndstopsStream(Printer, processWriteRegExStream11); + totalGCodeStream = softwareEndstopsExStream12; +#endif // Force a reset of the printer checksum state (but allow it to be write regexed) var transformedCommand = processWriteRegExStream11?.ProcessWriteRegEx("M110 N1"); diff --git a/MatterControlLib/SlicerConfiguration/EngineMappingMatterSlice.cs b/MatterControlLib/SlicerConfiguration/EngineMappingMatterSlice.cs index 9a362bfbe..e94a8da54 100644 --- a/MatterControlLib/SlicerConfiguration/EngineMappingMatterSlice.cs +++ b/MatterControlLib/SlicerConfiguration/EngineMappingMatterSlice.cs @@ -159,9 +159,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration new AsPercentOfReferenceOrDirect(printer, SettingsKey.first_layer_extrusion_width, "firstLayerExtrusionWidth", SettingsKey.nozzle_diameter), new AsPercentOfReferenceOrDirect(printer, SettingsKey.first_layer_height, "firstLayerThickness", SettingsKey.layer_height), new GCodeForSlicer(printer, SettingsKey.end_gcode, "endCode"), - new GCodeForSlicer(printer, SettingsKey.before_toolchange_gcode, "beforeToolchangeCode"), new GCodeForSlicer(printer, SettingsKey.toolchange_gcode, "toolChangeCode"), - new GCodeForSlicer(printer, SettingsKey.before_toolchange_gcode_1, "beforeToolchangeCode1"), new GCodeForSlicer(printer, SettingsKey.toolchange_gcode_1, "toolChangeCode1"), new MapFirstValue(printer, SettingsKey.retract_before_travel, "minimumTravelToCauseRetraction"), new RetractionLength(printer, SettingsKey.retract_length, "retractionOnTravel"), diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 2572ad0b2..d93dba440 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 2572ad0b29d45fb647ef4d0d5d4dcc2e38e308e4 +Subproject commit d93dba440e76111af31c3c873a3d5c2bfc8c0d5a diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index d53980a7d..1e4317a90 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit d53980a7dc44efd0d3ecad0213caf78a3da5128f +Subproject commit 1e4317a904e923f338dde1600d65bce11bb46b97 diff --git a/Tests/MatterControl.Tests/MatterControl/GCodeStreamTests.cs b/Tests/MatterControl.Tests/MatterControl/GCodeStreamTests.cs index 576393a51..5d01fa2ce 100644 --- a/Tests/MatterControl.Tests/MatterControl/GCodeStreamTests.cs +++ b/Tests/MatterControl.Tests/MatterControl/GCodeStreamTests.cs @@ -559,6 +559,74 @@ namespace MatterControl.Tests.MatterControl } } + [Test, Category("GCodeStream"), Ignore("WIP")] + public void SoftwareEndstopstreamTests() + { + string[] inputLines = new string[] + { + // test x min + // move without extrusion + "G1 X100Y100Z0E0", // start at the bed center + "G1 X-100", // move left off the bed + "G1 Y110", // move while outside bounds + "G1 X100", // move back on + + // move with extrusion + "G1 X100Y100Z0E0", // start at the bed center + "G1 X-100E10", // move left off the bed + "G1 Y110E20", // move while outside bounds + "G1 X100E30", // move back on + + // test x max + // test y min + // test y max + // test z min + // test z max + + null, + }; + + // We should go back to the above code when possible. It requires making pause part and move while paused part of the stream. + // All communication should go through stream to minimize the difference between printing and controlling while not printing (all printing in essence). + string[] expected = new string[] + { + // move without extrusion + "G1 X100 Y100 Z0 E0", // strat position + "G1 X0", // clamped x + "", // move while outside + "G1 Y110", // first position back in bounds + "G1 X100", // move to requested x + + // move with extrusion + "G1 X100Y100Z0E0", // start at the bed center + "G1 X-100E10", // move left off the bed + "G1 Y110E20", // move while outside bounds + "G1 X100E30", // move back on + + null, + }; + + AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData")); + MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4)); + + var printer = new PrinterConfig(new PrinterSettings()); + var pauseHandlingStream = new SoftwareEndstopsStream(printer, new TestGCodeStream(printer, inputLines)); + + int expectedIndex = 0; + string actualLine = pauseHandlingStream.ReadLine(); + string expectedLine = expected[expectedIndex++]; + + Assert.AreEqual(expectedLine, actualLine, "Unexpected response from PauseHandlingStream"); + + while (actualLine != null) + { + expectedLine = expected[expectedIndex++]; + actualLine = pauseHandlingStream.ReadLine(); + + Assert.AreEqual(expectedLine, actualLine, "Unexpected response from PauseHandlingStream"); + } + } + [Test, Category("GCodeStream")] public void MorePauseHandlingStreamTests() {