From 81e3cc1425f2bbe8e461b9bc4af88b5f81616451 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 29 Jun 2017 13:35:44 -0700 Subject: [PATCH] Rename NumChangesInZ to LayerCount --- ApplicationView/ApplicationController.cs | 6 +++--- MatterControl.OpenGL/GCodeRenderer/GCodeRenderer.cs | 10 +++++----- MatterControl.Printing/GCode/GCodeFile.cs | 2 +- MatterControl.Printing/GCode/GCodeFileLoaded.cs | 8 ++++---- MatterControl.Printing/GCode/GCodeFileStreamed.cs | 2 +- PartPreviewWindow/GCode2DWidget.cs | 2 +- PartPreviewWindow/LayerNavigationWidget.cs | 2 +- PartPreviewWindow/ViewGcodeBasic.cs | 2 +- PrinterCommunication/PrinterConnection.cs | 3 +-- 9 files changed, 18 insertions(+), 19 deletions(-) diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index c7f5e329c..a3d5dc187 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -94,13 +94,13 @@ namespace MatterHackers.MatterControl { activeLayerIndex = 0; } - else if (activeLayerIndex >= this.LoadedGCode.NumChangesInZ) + else if (activeLayerIndex >= this.LoadedGCode.LayerCount) { - activeLayerIndex = this.LoadedGCode.NumChangesInZ - 1; + activeLayerIndex = this.LoadedGCode.LayerCount - 1; } // When the active layer changes we update the selected range accordingly - constrain to applicable values - this.RenderInfo.EndLayerIndex = Math.Min(this.LoadedGCode.NumChangesInZ - 1, Math.Max(activeLayerIndex, 1)); + this.RenderInfo.EndLayerIndex = Math.Min(this.LoadedGCode.LayerCount - 1, Math.Max(activeLayerIndex, 1)); ActiveLayerChanged?.Invoke(this, null); } diff --git a/MatterControl.OpenGL/GCodeRenderer/GCodeRenderer.cs b/MatterControl.OpenGL/GCodeRenderer/GCodeRenderer.cs index c581e27ea..c421bb5c4 100644 --- a/MatterControl.OpenGL/GCodeRenderer/GCodeRenderer.cs +++ b/MatterControl.OpenGL/GCodeRenderer/GCodeRenderer.cs @@ -71,7 +71,7 @@ namespace MatterHackers.GCodeVisualizer { this.gCodeFileToDraw = gCodeFileToDraw; - for (int i = 0; i < gCodeFileToDraw.NumChangesInZ; i++) + for (int i = 0; i < gCodeFileToDraw.LayerCount; i++) { renderFeatures.Add(new List()); } @@ -114,7 +114,7 @@ namespace MatterHackers.GCodeVisualizer int startRenderIndex = gCodeFileToDraw.GetInstructionIndexAtLayer(layerToCreate); int endRenderIndex = gCodeFileToDraw.LineCount - 1; - if (layerToCreate < gCodeFileToDraw.NumChangesInZ - 1) + if (layerToCreate < gCodeFileToDraw.LayerCount - 1) { endRenderIndex = gCodeFileToDraw.GetInstructionIndexAtLayer(layerToCreate + 1); } @@ -283,8 +283,8 @@ namespace MatterHackers.GCodeVisualizer if (layerVertexBuffer == null) { layerVertexBuffer = new List(); - layerVertexBuffer.Capacity = gCodeFileToDraw.NumChangesInZ; - for (int layerIndex = 0; layerIndex < gCodeFileToDraw.NumChangesInZ; layerIndex++) + layerVertexBuffer.Capacity = gCodeFileToDraw.LayerCount; + for (int layerIndex = 0; layerIndex < gCodeFileToDraw.LayerCount; layerIndex++) { layerVertexBuffer.Add(null); featureStartIndex.Add(new List()); @@ -292,7 +292,7 @@ namespace MatterHackers.GCodeVisualizer } } - for (int layerIndex = 0; layerIndex < gCodeFileToDraw.NumChangesInZ; layerIndex++) + for (int layerIndex = 0; layerIndex < gCodeFileToDraw.LayerCount; layerIndex++) { CreateFeaturesForLayerIfRequired(layerIndex); } diff --git a/MatterControl.Printing/GCode/GCodeFile.cs b/MatterControl.Printing/GCode/GCodeFile.cs index c3adbf72b..74f90ea60 100644 --- a/MatterControl.Printing/GCode/GCodeFile.cs +++ b/MatterControl.Printing/GCode/GCodeFile.cs @@ -59,7 +59,7 @@ namespace MatterHackers.GCodeVisualizer // the number of lines in the file public abstract int LineCount { get; } - public abstract int NumChangesInZ { get; } + public abstract int LayerCount { get; } public abstract double TotalSecondsInPrint { get; } public abstract void Clear(); diff --git a/MatterControl.Printing/GCode/GCodeFileLoaded.cs b/MatterControl.Printing/GCode/GCodeFileLoaded.cs index bd6840bc8..371715181 100644 --- a/MatterControl.Printing/GCode/GCodeFileLoaded.cs +++ b/MatterControl.Printing/GCode/GCodeFileLoaded.cs @@ -395,7 +395,7 @@ namespace MatterHackers.GCodeVisualizer get { return indexOfChangeInZ; } } - public override int NumChangesInZ + public override int LayerCount { get { return indexOfChangeInZ.Count; } } @@ -928,7 +928,7 @@ namespace MatterHackers.GCodeVisualizer if (instructionIndex >= 0 && instructionIndex < LineCount) { - for (int zIndex = 0; zIndex < NumChangesInZ; zIndex++) + for (int zIndex = 0; zIndex < LayerCount; zIndex++) { if (instructionIndex < IndexOfChangeInZ[zIndex]) { @@ -936,7 +936,7 @@ namespace MatterHackers.GCodeVisualizer } } - return NumChangesInZ - 1; + return LayerCount - 1; } return -1; @@ -954,7 +954,7 @@ namespace MatterHackers.GCodeVisualizer startIndex = IndexOfChangeInZ[currentLayer - 1]; } int endIndex = LineCount - 1; - if (currentLayer < NumChangesInZ - 1) + if (currentLayer < LayerCount - 1) { endIndex = IndexOfChangeInZ[currentLayer]; } diff --git a/MatterControl.Printing/GCode/GCodeFileStreamed.cs b/MatterControl.Printing/GCode/GCodeFileStreamed.cs index 9e6017a6b..e51e1c2cf 100644 --- a/MatterControl.Printing/GCode/GCodeFileStreamed.cs +++ b/MatterControl.Printing/GCode/GCodeFileStreamed.cs @@ -193,7 +193,7 @@ namespace MatterHackers.GCodeVisualizer return 0; } - public override int NumChangesInZ + public override int LayerCount { get { diff --git a/PartPreviewWindow/GCode2DWidget.cs b/PartPreviewWindow/GCode2DWidget.cs index da23239f5..dc803c72c 100644 --- a/PartPreviewWindow/GCode2DWidget.cs +++ b/PartPreviewWindow/GCode2DWidget.cs @@ -128,7 +128,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (firstExtrusionIndex > 0) { - for (int layerIndex = 0; layerIndex < loadedGCode.NumChangesInZ; layerIndex++) + for (int layerIndex = 0; layerIndex < loadedGCode.LayerCount; layerIndex++) { if (firstExtrusionIndex < loadedGCode.GetInstructionIndexAtLayer(layerIndex)) { diff --git a/PartPreviewWindow/LayerNavigationWidget.cs b/PartPreviewWindow/LayerNavigationWidget.cs index a606e2db1..bae606036 100644 --- a/PartPreviewWindow/LayerNavigationWidget.cs +++ b/PartPreviewWindow/LayerNavigationWidget.cs @@ -75,7 +75,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { if (printer.BedPlate.LoadedGCode != null) { - layerCountTextWidget.Text = string.Format("{0} / {1}", printer.BedPlate.ActiveLayerIndex + 1, printer.BedPlate.LoadedGCode.NumChangesInZ.ToString()); + layerCountTextWidget.Text = string.Format("{0} / {1}", printer.BedPlate.ActiveLayerIndex + 1, printer.BedPlate.LoadedGCode.LayerCount); } base.OnDraw(graphics2D); diff --git a/PartPreviewWindow/ViewGcodeBasic.cs b/PartPreviewWindow/ViewGcodeBasic.cs index 38d7f1131..28e361303 100644 --- a/PartPreviewWindow/ViewGcodeBasic.cs +++ b/PartPreviewWindow/ViewGcodeBasic.cs @@ -699,7 +699,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow layerSelectionButtonsPanel.AddChild(navigationWidget); selectLayerSlider?.Close(); - selectLayerSlider = new SolidSlider(new Vector2(), sliderWidth, 0, loadedGCode.NumChangesInZ - 1, Orientation.Vertical); + selectLayerSlider = new SolidSlider(new Vector2(), sliderWidth, 0, loadedGCode.LayerCount - 1, Orientation.Vertical); selectLayerSlider.ValueChanged += (s, e) => { // TODO: Why would these need to be updated here as well as in assigned in the hslider below? diff --git a/PrinterCommunication/PrinterConnection.cs b/PrinterCommunication/PrinterConnection.cs index 522c964fa..4d2bfa093 100644 --- a/PrinterCommunication/PrinterConnection.cs +++ b/PrinterCommunication/PrinterConnection.cs @@ -876,8 +876,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication { try { - int layerCount = loadedGCode.NumChangesInZ; - return layerCount; + return loadedGCode.LayerCount; } catch (Exception) {