From 9f6b6133ac2021294347b836670b8bbd2255c643 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 31 Oct 2023 15:13:04 -0700 Subject: [PATCH] refactoring --- .../RenderFeatures/RenderFeatureExtrusion.cs | 4 ++-- .../RenderFeatures/RenderFeatureTravel.cs | 6 +++--- .../DesignTools/Braille/BrailleObject3D.cs | 18 +++++++++--------- .../EditorTools/RotateControls/PathControl.cs | 18 +++++++++--------- .../Operations/FitToCylinderObject3D.cs | 2 +- .../Operations/Object3DExtensions.cs | 8 ++++---- .../Operations/Path/OutlinePathObject3D.cs | 2 +- .../Operations/RadialPinchObject3D.cs | 4 ---- .../DesignTools/Primitives/Gear2D.cs | 10 +++++----- .../Primitives/VertexSourceExtensions.cs | 2 +- .../PartPreviewWindow/PlatingHelper.cs | 6 +++--- Submodules/MatterSlice | 2 +- Submodules/agg-sharp | 2 +- 13 files changed, 40 insertions(+), 44 deletions(-) diff --git a/MatterControl.OpenGL/GCodeRenderer/RenderFeatures/RenderFeatureExtrusion.cs b/MatterControl.OpenGL/GCodeRenderer/RenderFeatures/RenderFeatureExtrusion.cs index 5c88210fa..3f6812f52 100644 --- a/MatterControl.OpenGL/GCodeRenderer/RenderFeatures/RenderFeatureExtrusion.cs +++ b/MatterControl.OpenGL/GCodeRenderer/RenderFeatures/RenderFeatureExtrusion.cs @@ -167,8 +167,8 @@ namespace MatterHackers.GCodeVisualizer LineJoin = LineJoin.Round }; - pathStorage.Add(start.X, start.Y, ShapePath.FlagsAndCommand.MoveTo); - pathStorage.Add(end.X, end.Y, ShapePath.FlagsAndCommand.LineTo); + pathStorage.Add(start.X, start.Y, FlagsAndCommand.MoveTo); + pathStorage.Add(end.X, end.Y, FlagsAndCommand.LineTo); graphics2D.Render(stroke, extrusionColor); } diff --git a/MatterControl.OpenGL/GCodeRenderer/RenderFeatures/RenderFeatureTravel.cs b/MatterControl.OpenGL/GCodeRenderer/RenderFeatures/RenderFeatureTravel.cs index 34516c282..e6f7616a5 100644 --- a/MatterControl.OpenGL/GCodeRenderer/RenderFeatures/RenderFeatureTravel.cs +++ b/MatterControl.OpenGL/GCodeRenderer/RenderFeatures/RenderFeatureTravel.cs @@ -109,14 +109,14 @@ namespace MatterHackers.GCodeVisualizer LineJoin = LineJoin.Round }; - pathStorage.Add(start.X, start.Y, ShapePath.FlagsAndCommand.MoveTo); + pathStorage.Add(start.X, start.Y, FlagsAndCommand.MoveTo); if (end.X != start.X || end.Y != start.Y) { - pathStorage.Add(end.X, end.Y, ShapePath.FlagsAndCommand.LineTo); + pathStorage.Add(end.X, end.Y, FlagsAndCommand.LineTo); } else { - pathStorage.Add(end.X + .01, end.Y, ShapePath.FlagsAndCommand.LineTo); + pathStorage.Add(end.X + .01, end.Y, FlagsAndCommand.LineTo); } graphics2D.Render(stroke, movementColor); diff --git a/MatterControlLib/DesignTools/Braille/BrailleObject3D.cs b/MatterControlLib/DesignTools/Braille/BrailleObject3D.cs index 7d3f541b9..71f38339f 100644 --- a/MatterControlLib/DesignTools/Braille/BrailleObject3D.cs +++ b/MatterControlLib/DesignTools/Braille/BrailleObject3D.cs @@ -148,12 +148,12 @@ namespace MatterHackers.MatterControl.DesignTools // find each dot outline and get it's center and place a sphere there foreach (var vertex in scalledLetterPrinter.Vertices()) { - switch (vertex.command) + switch (vertex.Command) { - case Agg.ShapePath.FlagsAndCommand.Stop: - case Agg.ShapePath.FlagsAndCommand.EndPoly: - case Agg.ShapePath.FlagsAndCommand.FlagClose: - case Agg.ShapePath.FlagsAndCommand.MoveTo: + case Agg.FlagsAndCommand.Stop: + case Agg.FlagsAndCommand.EndPoly: + case Agg.FlagsAndCommand.FlagClose: + case Agg.FlagsAndCommand.MoveTo: if (vertexCount > 0) { var center = positionSum / vertexCount; @@ -168,11 +168,11 @@ namespace MatterHackers.MatterControl.DesignTools vertexCount = 0; positionSum = Vector2.Zero; break; - case Agg.ShapePath.FlagsAndCommand.Curve3: - case Agg.ShapePath.FlagsAndCommand.Curve4: - case Agg.ShapePath.FlagsAndCommand.LineTo: + case Agg.FlagsAndCommand.Curve3: + case Agg.FlagsAndCommand.Curve4: + case Agg.FlagsAndCommand.LineTo: vertexCount++; - lastPosition = vertex.position; + lastPosition = vertex.Position; positionSum += lastPosition; break; } diff --git a/MatterControlLib/DesignTools/EditorTools/RotateControls/PathControl.cs b/MatterControlLib/DesignTools/EditorTools/RotateControls/PathControl.cs index 3262d9285..416ce781c 100644 --- a/MatterControlLib/DesignTools/EditorTools/RotateControls/PathControl.cs +++ b/MatterControlLib/DesignTools/EditorTools/RotateControls/PathControl.cs @@ -126,7 +126,7 @@ namespace MatterHackers.Plugins.EditorTools if (flattened != null && e.Graphics2D is Graphics2DOpenGL glGraphics) { - var pixelWidth = world.GetWorldUnitsPerScreenPixelAtPosition(new Vector3(activePoints.First().position)); + var pixelWidth = world.GetWorldUnitsPerScreenPixelAtPosition(new Vector3(activePoints.First().Position)); world.RenderPath( new Stroke(flattened, pixelWidth * .02), @@ -212,11 +212,11 @@ namespace MatterHackers.Plugins.EditorTools if (ShapePath.IsVertex(command)) { - if (command == ShapePath.FlagsAndCommand.Curve4) + if (command == FlagsAndCommand.Curve4) { - // vertexDataManager.AddVertex(x_ctrl1, y_ctrl1, ShapePath.FlagsAndCommand.Curve4); - // vertexDataManager.AddVertex(x_ctrl2, y_ctrl2, ShapePath.FlagsAndCommand.Curve4); - // vertexDataManager.AddVertex(x_to, y_to, ShapePath.FlagsAndCommand.Curve4); + // vertexDataManager.AddVertex(x_ctrl1, y_ctrl1, FlagsAndCommand.Curve4); + // vertexDataManager.AddVertex(x_ctrl2, y_ctrl2, FlagsAndCommand.Curve4); + // vertexDataManager.AddVertex(x_to, y_to, FlagsAndCommand.Curve4); var lastItem = targets.LastOrDefault(); @@ -314,7 +314,7 @@ namespace MatterHackers.Plugins.EditorTools private class CurveControlPoint : VertexPointWidget { - public CurveControlPoint(IObject3DControlContext context, PathControl pathControl, VertexStorage vertexStorage, Vector3 point, ShapePath.FlagsAndCommand flagsandCommand, int index) + public CurveControlPoint(IObject3DControlContext context, PathControl pathControl, VertexStorage vertexStorage, Vector3 point, FlagsAndCommand flagsandCommand, int index) : base(context, pathControl, vertexStorage, point, flagsandCommand, index) { this.ClaimSelection = false; @@ -329,7 +329,7 @@ namespace MatterHackers.Plugins.EditorTools { private readonly bool _focused; - public Curve4AnchorWidget(IObject3DControlContext context, PathControl pathControl, VertexStorage vertexStorage, Vector3 point, ShapePath.FlagsAndCommand flagsandCommand, int index) + public Curve4AnchorWidget(IObject3DControlContext context, PathControl pathControl, VertexStorage vertexStorage, Vector3 point, FlagsAndCommand flagsandCommand, int index) : base(context, pathControl, vertexStorage, point, flagsandCommand, index) { } @@ -360,14 +360,14 @@ namespace MatterHackers.Plugins.EditorTools { public PathControl PathControl { get; } - private readonly ShapePath.FlagsAndCommand command; + private readonly FlagsAndCommand command; private readonly VertexStorage vertexStorage; private Vector3 _point = Vector3.NegativeInfinity; private Vector3 controlPointDelta; private readonly int index; - public VertexPointWidget(IObject3DControlContext context, PathControl pathControl, VertexStorage vertexStorage, Vector3 point, ShapePath.FlagsAndCommand flagsandCommand, int index) + public VertexPointWidget(IObject3DControlContext context, PathControl pathControl, VertexStorage vertexStorage, Vector3 point, FlagsAndCommand flagsandCommand, int index) : base(context, point) { this.PathControl = pathControl; diff --git a/MatterControlLib/DesignTools/Operations/FitToCylinderObject3D.cs b/MatterControlLib/DesignTools/Operations/FitToCylinderObject3D.cs index 1bbe0f827..06d36d241 100644 --- a/MatterControlLib/DesignTools/Operations/FitToCylinderObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/FitToCylinderObject3D.cs @@ -189,7 +189,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations var center = vertexSource.GetBounds().Center; foreach (var vertex in vertexSource.Vertices()) { - var position = vertex.position; + var position = vertex.Position; var distSqrd = (new Vector2(position.X, position.Y) - new Vector2(center.X, center.Y)).LengthSquared; if (distSqrd > maxDistSqrd) { diff --git a/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs b/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs index 890314c61..40e49c00b 100644 --- a/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs +++ b/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs @@ -217,7 +217,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations var firstMove = Vector2.Zero; foreach (var vertex in item.GetVertexSource().Vertices()) { - var position = vertex.position; + var position = vertex.Position; if (first) { GL.PushMatrix(); @@ -272,7 +272,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations foreach (var vertex in item.GetVertexSource().Vertices()) { - var position = vertex.position; + var position = vertex.Position; if (vertex.IsLineTo) { @@ -332,7 +332,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public static Affine GetCenteringTransformExpandedToRadius(this IVertexSource vertexSource, double radius) { - var circle = SmallestEnclosingCircle.MakeCircle(vertexSource.Vertices().Select((v) => new Vector2(v.position.X, v.position.Y))); + var circle = SmallestEnclosingCircle.MakeCircle(vertexSource.Vertices().Select((v) => new Vector2(v.Position.X, v.Position.Y))); // move the circle center to the origin var centering = Affine.NewTranslation(-circle.Center); @@ -378,7 +378,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations var center = vertexSource.GetBounds().Center; foreach (var vertex in vertexSource.Vertices()) { - var position = vertex.position; + var position = vertex.Position; var distSqrd = (new Vector2(position.X, position.Y) - new Vector2(center.X, center.Y)).LengthSquared; if (distSqrd > maxDistSqrd) { diff --git a/MatterControlLib/DesignTools/Operations/Path/OutlinePathObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/OutlinePathObject3D.cs index 6ed7a0c81..2b0eb53ca 100644 --- a/MatterControlLib/DesignTools/Operations/Path/OutlinePathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/OutlinePathObject3D.cs @@ -151,7 +151,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations VertexStorage = allLoops.CreateVertexStorage(); - VertexStorage.Add(0, 0, ShapePath.FlagsAndCommand.Stop); + VertexStorage.Add(0, 0, FlagsAndCommand.Stop); } } } \ No newline at end of file diff --git a/MatterControlLib/DesignTools/Operations/RadialPinchObject3D.cs b/MatterControlLib/DesignTools/Operations/RadialPinchObject3D.cs index 0a17a16fe..2f2926699 100644 --- a/MatterControlLib/DesignTools/Operations/RadialPinchObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/RadialPinchObject3D.cs @@ -51,7 +51,6 @@ namespace MatterHackers.MatterControl.DesignTools { public class PathEditor : IPropertyEditorFactory { - private ulong lastRenderHashCode = 0; private Action vertexChanged; private ThemeConfig theme; private VertexStorage vertexStorage; @@ -210,8 +209,6 @@ namespace MatterHackers.MatterControl.DesignTools public Vector2 Point6 { get; set;} = new Vector2(5, 16); public Vector2 Point7 { get; set;} = new Vector2(6, 18); public Vector2 Point8 { get; set;} = new Vector2(7, 20); - public Vector2 Point9 { get; set;} = new Vector2(8, 22); - public Vector2 Point10 { get; set;} = new Vector2(9, 24); @@ -275,7 +272,6 @@ namespace MatterHackers.MatterControl.DesignTools PathForHorizontalOffsets.MoveTo(Point1); PathForHorizontalOffsets.Curve4(Point2, Point3, Point4); PathForHorizontalOffsets.Curve4(Point5, Point6, Point7); - PathForHorizontalOffsets.Curve4(Point8, Point9, Point10); } var horizontalOffset = new FlattenCurves(new VertexSourceApplyTransform(PathForHorizontalOffsets, Affine.NewScaling(10))); diff --git a/MatterControlLib/DesignTools/Primitives/Gear2D.cs b/MatterControlLib/DesignTools/Primitives/Gear2D.cs index c5b33afed..484fa3e97 100644 --- a/MatterControlLib/DesignTools/Primitives/Gear2D.cs +++ b/MatterControlLib/DesignTools/Primitives/Gear2D.cs @@ -266,19 +266,19 @@ namespace MatterHackers.MatterControl.DesignTools if (shape == null) { - yield return new VertexData(ShapePath.FlagsAndCommand.MoveTo, 0, 0); - yield return new VertexData(ShapePath.FlagsAndCommand.LineTo, 20, 0); - yield return new VertexData(ShapePath.FlagsAndCommand.LineTo, 0, 20); + yield return new VertexData(FlagsAndCommand.MoveTo, 0, 0); + yield return new VertexData(FlagsAndCommand.LineTo, 20, 0); + yield return new VertexData(FlagsAndCommand.LineTo, 0, 20); } else { foreach (var poly in shape) { - var command = ShapePath.FlagsAndCommand.MoveTo; + var command = FlagsAndCommand.MoveTo; foreach (var point in poly) { yield return new VertexData(command, point.X / 1000.0, point.Y / 1000.0); - command = ShapePath.FlagsAndCommand.LineTo; + command = FlagsAndCommand.LineTo; } } } diff --git a/MatterControlLib/DesignTools/Primitives/VertexSourceExtensions.cs b/MatterControlLib/DesignTools/Primitives/VertexSourceExtensions.cs index c60ede92e..8cf5fdba8 100644 --- a/MatterControlLib/DesignTools/Primitives/VertexSourceExtensions.cs +++ b/MatterControlLib/DesignTools/Primitives/VertexSourceExtensions.cs @@ -84,7 +84,7 @@ public static class VertexSourceExtensions VertexStorage output = outputPolys.CreateVertexStorage(); - output.Add(0, 0, ShapePath.FlagsAndCommand.Stop); + output.Add(0, 0, FlagsAndCommand.Stop); return output; } diff --git a/MatterControlLib/PartPreviewWindow/PlatingHelper.cs b/MatterControlLib/PartPreviewWindow/PlatingHelper.cs index 61965ed10..9ba990819 100644 --- a/MatterControlLib/PartPreviewWindow/PlatingHelper.cs +++ b/MatterControlLib/PartPreviewWindow/PlatingHelper.cs @@ -54,19 +54,19 @@ namespace MatterHackers.MatterControl { if (first) { - output.Add(point.X, point.Y, ShapePath.FlagsAndCommand.MoveTo); + output.Add(point.X, point.Y, FlagsAndCommand.MoveTo); first = false; } else { - output.Add(point.X, point.Y, ShapePath.FlagsAndCommand.LineTo); + output.Add(point.X, point.Y, FlagsAndCommand.LineTo); } } output.ClosePolygon(); } - output.Add(0, 0, ShapePath.FlagsAndCommand.Stop); + output.Add(0, 0, FlagsAndCommand.Stop); return output; } diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 00b99afed..a0f8da359 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 00b99afed26b58d9c3a25eafa891fcef0dfd89de +Subproject commit a0f8da359b9d116934a8ff86101407e5dcb698e2 diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index c19b0609c..91d15ff1d 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit c19b0609c41c64e5eb90961cd80b211abc08c0d9 +Subproject commit 91d15ff1d8a9d934c309de1279f977ce0537a9c9