diff --git a/CustomWidgets/ExportPrintItemWindow.cs b/CustomWidgets/ExportPrintItemWindow.cs index 996df5885..d6324356c 100644 --- a/CustomWidgets/ExportPrintItemWindow.cs +++ b/CustomWidgets/ExportPrintItemWindow.cs @@ -398,7 +398,7 @@ namespace MatterHackers.MatterControl { if (ActivePrinterProfile.Instance.DoPrintLeveling) { - GCodeFile unleveledGCode = new GCodeFile(source); + GCodeFileLoaded unleveledGCode = new GCodeFileLoaded(source); if (applyLeveling.Checked) { PrintLevelingPlane.Instance.ApplyLeveling(unleveledGCode); diff --git a/PartPreviewWindow/ViewGcodeWidget.cs b/PartPreviewWindow/ViewGcodeWidget.cs index 6a3c2a351..cbdcad6ea 100644 --- a/PartPreviewWindow/ViewGcodeWidget.cs +++ b/PartPreviewWindow/ViewGcodeWidget.cs @@ -264,11 +264,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (firstExtrusionIndex > 0) { - for (int i = 0; i < loadedGCode.NumChangesInZ; i++) + for (int layerIndex = 0; layerIndex < loadedGCode.NumChangesInZ; layerIndex++) { - if (firstExtrusionIndex < loadedGCode.IndexOfChangeInZ[i]) + if (firstExtrusionIndex < loadedGCode.GetInstructionIndexAtLayer(layerIndex)) { - activeLayerIndex = Math.Max(0, i-1); + activeLayerIndex = Math.Max(0, layerIndex-1); break; } } @@ -481,7 +481,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public void Load(string gcodePathAndFileName) { - loadedGCode = new GCodeFile(gcodePathAndFileName); + loadedGCode = GCodeFile.Load(gcodePathAndFileName); SetInitalLayer(); CenterPartInView(); } @@ -497,7 +497,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(initialLoading_RunWorkerCompleted); loadedGCode = null; - GCodeFile.LoadInBackground(backgroundWorker, gcodePathAndFileName); + GCodeFileLoaded.LoadInBackground(backgroundWorker, gcodePathAndFileName); } public override void OnClosed(EventArgs e) diff --git a/PrintQueue/OptionsMenu/ExportToFolderProcess.cs b/PrintQueue/OptionsMenu/ExportToFolderProcess.cs index ffad912f2..97fca6de8 100644 --- a/PrintQueue/OptionsMenu/ExportToFolderProcess.cs +++ b/PrintQueue/OptionsMenu/ExportToFolderProcess.cs @@ -177,11 +177,6 @@ namespace MatterHackers.MatterControl.PrintQueue } } } - if (!foundAmountInGCode) - { - GCodeFile gcodeFile = new GCodeFile(gcodeFileName); - total += gcodeFile.GetFilamentCubicMm(ActiveSliceSettings.Instance.FilamentDiameter) / 1000; - } } } @@ -195,7 +190,7 @@ namespace MatterHackers.MatterControl.PrintQueue if (ActivePrinterProfile.Instance.DoPrintLeveling) { - GCodeFile unleveledGCode = new GCodeFile(savedGcodeFileName); + GCodeFileLoaded unleveledGCode = new GCodeFileLoaded(savedGcodeFileName); PrintLevelingPlane.Instance.ApplyLeveling(unleveledGCode); unleveledGCode.Save(outputPathAndName); } diff --git a/PrinterCommunication/Io/PrinterIoGCodeFile.cs b/PrinterCommunication/Io/PrinterIoGCodeFile.cs index bf5613148..4d54b84b7 100644 --- a/PrinterCommunication/Io/PrinterIoGCodeFile.cs +++ b/PrinterCommunication/Io/PrinterIoGCodeFile.cs @@ -37,7 +37,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io { public class PrinterIoGCodeFile : PrinterIoBase { - GCodeFile loadedGCode = new GCodeFile(); + GCodeFile loadedGCode; int printerCommandQueueIndex; public PrinterIoGCodeFile(GCodeFile loadedGCode) { @@ -68,7 +68,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io { for (int zIndex = 0; zIndex < loadedGCode.NumChangesInZ; zIndex++) { - if (currentIndex < loadedGCode.IndexOfChangeInZ[zIndex]) + if (currentIndex < loadedGCode.GetInstructionIndexAtLayer(zIndex)) { return zIndex - 1; } @@ -106,11 +106,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io && currentIndex < loadedGCode.Count) { int currentLayer = CurrentlyPrintingLayer; - int startIndex = loadedGCode.IndexOfChangeInZ[currentLayer]; + int startIndex = loadedGCode.GetInstructionIndexAtLayer(currentLayer); int endIndex = loadedGCode.Count - 1; if (currentLayer < loadedGCode.NumChangesInZ - 2) { - endIndex = loadedGCode.IndexOfChangeInZ[currentLayer + 1] - 1; + endIndex = loadedGCode.GetInstructionIndexAtLayer(currentLayer + 1) - 1; } int deltaFromStart = Math.Max(0, currentIndex - startIndex); diff --git a/PrinterCommunication/PrinterConnectionAndCommunication.cs b/PrinterCommunication/PrinterConnectionAndCommunication.cs index f7d8ffe92..fcdc22399 100644 --- a/PrinterCommunication/PrinterConnectionAndCommunication.cs +++ b/PrinterCommunication/PrinterConnectionAndCommunication.cs @@ -296,7 +296,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication double actualBedTemperature; double targetBedTemperature; string printJobDisplayName = null; - GCodeFile loadedGCode = new GCodeFile(); + GCodeFile loadedGCode = new GCodeFileLoaded(); // we start out by setting it to a nothing file IFrostedSerialPort serialPort; Thread readFromPrinterThread; Thread connectThread; @@ -2450,7 +2450,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication LinesToWriteQueue.Clear(); ClearQueuedGCode(); - loadedGCode = new GCodeFile(gcodeFilename); + loadedGCode = GCodeFile.Load(gcodeFilename); switch (communicationState) {