From c3f434fe3eed23b44e090fbf8a2da702c3d6e268 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Mon, 2 Nov 2020 18:24:19 -0800 Subject: [PATCH] Merge branch 'master' of https://github.com/MatterHackers/MatterControl # Conflicts: # MatterControl.Printing/Settings/PrinterSettingsLayer.cs # MatterControlLib/SlicerConfiguration/Settings/ProfileManager.cs --- .../History/PrintHistoryEditor.cs | 2 +- .../Io/RelativeToAbsoluteStream.cs | 96 ++++++++++--------- 2 files changed, 50 insertions(+), 48 deletions(-) diff --git a/MatterControlLib/History/PrintHistoryEditor.cs b/MatterControlLib/History/PrintHistoryEditor.cs index 63bf607fa..45e149580 100644 --- a/MatterControlLib/History/PrintHistoryEditor.cs +++ b/MatterControlLib/History/PrintHistoryEditor.cs @@ -493,7 +493,7 @@ Support and tutorials:" + articles; { UiThread.RunOnIdle(() => { - DialogWindow.Show(this, 0); + DialogWindow.Show(this, printTask.Id); // this will cause a layout that fixes a display issue scrollable.ScrollArea.BoundsChanged += (s, e) => { diff --git a/MatterControlLib/PrinterCommunication/Io/RelativeToAbsoluteStream.cs b/MatterControlLib/PrinterCommunication/Io/RelativeToAbsoluteStream.cs index 86e76137b..c47f9911b 100644 --- a/MatterControlLib/PrinterCommunication/Io/RelativeToAbsoluteStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/RelativeToAbsoluteStream.cs @@ -27,22 +27,16 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -using System; -using MatterHackers.Agg; -using MatterHackers.GCodeVisualizer; -using MatterHackers.VectorMath; -using System.Text; -using System.Collections.Generic; - namespace MatterHackers.MatterControl.PrinterCommunication.Io { public class RelativeToAbsoluteStream : GCodeStreamProxy { protected PrinterMove lastDestination = PrinterMove.Unknown; + public PrinterMove LastDestination { get { return lastDestination; } } - bool xyzAbsoluteMode = true; - bool eAbsoluteMode = true; + private bool xyzAbsoluteMode = true; + private bool eAbsoluteMode = true; private bool haveSentG90; public RelativeToAbsoluteStream(PrinterConfig printer, GCodeStream internalStream) @@ -66,34 +60,39 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io public string ProcessLine(string lineToProcess) { - if (lineToProcess != null - && lineToProcess.StartsWith("G9")) + if (lineToProcess != null) { - if (lineToProcess.StartsWith("G91")) + if (lineToProcess.StartsWith("G9")) { - xyzAbsoluteMode = false; - eAbsoluteMode = false; - return ""; - } - else if (lineToProcess.StartsWith("G90")) - { - xyzAbsoluteMode = true; - eAbsoluteMode = true; - if (haveSentG90) + if (lineToProcess.StartsWith("G91")) { - // If we have already set the printer to absolute mode, do not send it again. - // This will guarantee we send it once and then we don't send it again (as this ensures we never send a G91). + xyzAbsoluteMode = false; + eAbsoluteMode = false; + // do not actually send this to the printer return ""; } - haveSentG90 = true; - } + else if (lineToProcess.StartsWith("G90")) + { + xyzAbsoluteMode = true; + eAbsoluteMode = true; + if (haveSentG90) + { + // If we have already set the printer to absolute mode, do not send it again. + // This will guarantee we send it once and then we don't send it again (as this ensures we never send a G91). + return ""; + } - if (lineToProcess.StartsWith("M83")) + haveSentG90 = true; + } + } + else if (lineToProcess.StartsWith("M83")) { // extruder to relative mode eAbsoluteMode = false; + // do not actually send this to the printer + return ""; } - else if (lineToProcess.StartsWith("82")) + else if (lineToProcess.StartsWith("M82")) { // extruder to absolute mode eAbsoluteMode = true; @@ -111,29 +110,32 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io else { PrinterMove xyzDestination = GetPosition(lineToProcess, lastDestination); - double feedRate = xyzDestination.feedRate; - if (!xyzAbsoluteMode) + if (xyzDestination.HaveAnyPosition) { - xyzDestination = GetPosition(lineToProcess, PrinterMove.Zero); - xyzDestination += lastDestination; + double feedRate = xyzDestination.feedRate; + if (!xyzAbsoluteMode) + { + xyzDestination = GetPosition(lineToProcess, PrinterMove.Zero); + xyzDestination += lastDestination; + } + + PrinterMove eDestination = GetPosition(lineToProcess, lastDestination); + if (!eAbsoluteMode) + { + eDestination = GetPosition(lineToProcess, PrinterMove.Zero); + eDestination += lastDestination; + } + + currentDestination.extrusion = eDestination.extrusion; + currentDestination.feedRate = feedRate; + currentDestination.position = xyzDestination.position; + + lineToProcess = CreateMovementLine(currentDestination, lastDestination); + + // send the first one + lastDestination = currentDestination; } - - PrinterMove eDestination = GetPosition(lineToProcess, lastDestination); - if (!eAbsoluteMode) - { - eDestination = GetPosition(lineToProcess, PrinterMove.Zero); - eDestination += lastDestination; - } - - currentDestination.extrusion = eDestination.extrusion; - currentDestination.feedRate = feedRate; - currentDestination.position = xyzDestination.position; - - lineToProcess = CreateMovementLine(currentDestination, lastDestination); } - - // send the first one - lastDestination = currentDestination; } return lineToProcess;