refactoring

This commit is contained in:
Lars Brubaker 2023-10-31 15:13:04 -07:00
parent d1beaf9490
commit 9f6b6133ac
13 changed files with 40 additions and 44 deletions

View file

@ -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);
}

View file

@ -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);

View file

@ -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;
}

View file

@ -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;

View file

@ -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)
{

View file

@ -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)
{

View file

@ -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);
}
}
}

View file

@ -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)));

View file

@ -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;
}
}
}

View file

@ -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;
}

View file

@ -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;
}

@ -1 +1 @@
Subproject commit 00b99afed26b58d9c3a25eafa891fcef0dfd89de
Subproject commit a0f8da359b9d116934a8ff86101407e5dcb698e2

@ -1 +1 @@
Subproject commit c19b0609c41c64e5eb90961cd80b211abc08c0d9
Subproject commit 91d15ff1d8a9d934c309de1279f977ce0537a9c9