diff --git a/MatterControlLib/DesignTools/Operations/RadialPinchObject3D.cs b/MatterControlLib/DesignTools/Operations/RadialPinchObject3D.cs index b498f6f5c..0a17a16fe 100644 --- a/MatterControlLib/DesignTools/Operations/RadialPinchObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/RadialPinchObject3D.cs @@ -51,50 +51,90 @@ namespace MatterHackers.MatterControl.DesignTools { public class PathEditor : IPropertyEditorFactory { + private ulong lastRenderHashCode = 0; + private Action vertexChanged; + private ThemeConfig theme; + private VertexStorage vertexStorage; + private GuiWidget container; + private ImageWidget imageWidget; + private Object3D object3D; + public GuiWidget CreateEditor(PropertyEditor propertyEditor, EditableProperty property, EditorContext context) { + if (property.Source is Object3D object3D) + { + this.object3D = object3D; + object3D.Invalidated += RebuildImage; + } + if (property.Value is VertexStorage vertexStorage) { - var container = new GuiWidget() - { - HAnchor = HAnchor.Stretch, - VAnchor = VAnchor.Stretch, - BackgroundOutlineWidth = 1, - BackgroundColor = Color.White, - BorderColor = Color.Black, - Margin = 1, - }; + var wdiget = CreateEditor(vertexStorage, propertyEditor.UndoBuffer, propertyEditor.Theme, VertexBufferChanged); + imageWidget.Closed += ImageWidget_Closed; - var imageWidget = new ImageWidget(100, 200) - { - AutoResize = true, - HAnchor = HAnchor.Center, - VAnchor = VAnchor.Center, - }; - container.AddChild(imageWidget); - - void RebuildImage(object item, EventArgs e) - { - imageWidget.Width = container.Width; - imageWidget.Height = container.Height; - imageWidget.Image.Allocate((int)container.Width, (int)container.Height, 32, new BlenderBGRA()); - - var graphics2D = imageWidget.Image.NewGraphics2D(); - - var bounds = imageWidget.Image.GetBounds(); - bounds.Inflate(-1); - graphics2D.Rectangle(bounds, Color.Red); - - vertexStorage.RenderCurve(graphics2D, Color.Black, 2, true); - } - - container.SizeChanged += RebuildImage; - - return container; + return wdiget; } return null; } + + private void VertexBufferChanged() + { + object3D.Invalidate(InvalidateType.Path); + } + + private void ImageWidget_Closed(object sender, EventArgs e) + { + imageWidget.Closed -= ImageWidget_Closed; + object3D.Invalidated -= RebuildImage; + } + + void RebuildImage(object item, EventArgs e) + { + imageWidget.Width = container.Width; + imageWidget.Height = container.Height; + imageWidget.Image.Allocate((int)container.Width, (int)container.Height, 32, new BlenderBGRA()); + + var graphics2D = imageWidget.Image.NewGraphics2D(); + graphics2D.Clear(theme.BackgroundColor); + + var bounds = imageWidget.Image.GetBounds(); + bounds.Inflate(-1); + graphics2D.Rectangle(bounds, theme.PrimaryAccentColor); + + var pathBounds = vertexStorage.GetBounds(); + + new VertexSourceApplyTransform(vertexStorage, Affine.NewScaling(1 / pathBounds.Height * bounds.Height)).RenderCurve(graphics2D, theme.TextColor, 2, true, theme.PrimaryAccentColor.Blend(theme.TextColor, .5), theme.PrimaryAccentColor); + } + + public GuiWidget CreateEditor(VertexStorage vertexStorage, UndoBuffer undoBuffer, ThemeConfig theme, Action vertexChanged) + { + this.vertexChanged = vertexChanged; + this.theme = theme; + this.vertexStorage = vertexStorage; + + container = new GuiWidget() + { + HAnchor = HAnchor.Stretch, + VAnchor = VAnchor.Stretch, + BackgroundOutlineWidth = 1, + BackgroundColor = Color.White, + BorderColor = Color.Black, + Margin = 1, + }; + + imageWidget = new ImageWidget(100, 200) + { + AutoResize = true, + HAnchor = HAnchor.Center, + VAnchor = VAnchor.Center, + }; + container.AddChild(imageWidget); + + container.SizeChanged += RebuildImage; + + return container; + } } public class RadialPinchObject3D : OperationSourceContainerObject3D, IPropertyGridModifier, IEditorDraw @@ -162,6 +202,19 @@ namespace MatterHackers.MatterControl.DesignTools return AxisAlignedBoundingBox.CenteredBox(new Vector3(1, 1, sourceAabb.ZSize), center).NewTransformed(this.WorldMatrix()); } + public Vector2 Point1 { get; set; } = new Vector2(0, 0); + public Vector2 Point2 {get; set;} = new Vector2(1, 4); + public Vector2 Point3 { get; set;} = new Vector2(2, 8); + public Vector2 Point4 { get; set;} = new Vector2(3, 12); + public Vector2 Point5 { get; set;} = new Vector2(4, 14); + 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); + + + public override Task Rebuild() { this.DebugDepth("Rebuild"); @@ -219,10 +272,10 @@ namespace MatterHackers.MatterControl.DesignTools middlePoint.X *= 2; PathForHorizontalOffsets.Clear(); - PathForHorizontalOffsets.MoveTo(bottomPoint); - PathForHorizontalOffsets.Curve4(bottomPoint, bottomPoint + new Vector2(.5, .5), middlePoint); - PathForHorizontalOffsets.Curve4(middlePoint - new Vector2(0, -1), middlePoint + new Vector2(0, 1), topPoint); - PathForHorizontalOffsets.Curve4(topPoint - new Vector2(.5, .5), topPoint, topPoint); + 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/SlicerConfiguration/UIFields/NumberField.cs b/MatterControlLib/SlicerConfiguration/UIFields/NumberField.cs index 7d26af987..5f52e4f65 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/NumberField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/NumberField.cs @@ -64,7 +64,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration }; } - private static void InternalTextEditWidget_KeyDown(object sender, KeyEventArgs e) + public static void InternalTextEditWidget_KeyDown(object sender, KeyEventArgs e) { var textEditWidget = sender as TextEditWidget; var internalTextEditWidget = textEditWidget.InternalTextEditWidget; diff --git a/MatterControlLib/SlicerConfiguration/UIFields/Vector2Field.cs b/MatterControlLib/SlicerConfiguration/UIFields/Vector2Field.cs index 9854e8b21..c41b3e8c0 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/Vector2Field.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/Vector2Field.cs @@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project. using System.Linq; using MatterHackers.Agg; using MatterHackers.Agg.UI; +using MatterHackers.MatterControl.DesignTools; using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.SlicerConfiguration @@ -82,10 +83,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { this.SetValue( string.Format("{0},{1}", xEditWidget.ActuallNumberEdit.Value.ToString("0.###"), yEditWidget.ActuallNumberEdit.Value.ToString("0.###")), - userInitiated: true); + userInitiated: true); }; - container.AddChild(xEditWidget); + xEditWidget.ActuallNumberEdit.KeyDown += NumberField.InternalTextEditWidget_KeyDown; + + container.AddChild(xEditWidget); double.TryParse(xyValueStrings[1], out double currentYValue); @@ -102,7 +105,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration userInitiated: true); }; - container.AddChild(yEditWidget); + yEditWidget.ActuallNumberEdit.KeyDown += NumberField.InternalTextEditWidget_KeyDown; + + container.AddChild(yEditWidget); this.Content = container; } diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index b24da83ee..0668fdc13 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -3805,6 +3805,36 @@ Translated:Plug in printer USB cable and turn printer on English:Plugins Translated:Plugins +English:Point 1 +Translated:Point 1 + +English:Point 10 +Translated:Point 10 + +English:Point 2 +Translated:Point 2 + +English:Point 3 +Translated:Point 3 + +English:Point 4 +Translated:Point 4 + +English:Point 5 +Translated:Point 5 + +English:Point 6 +Translated:Point 6 + +English:Point 7 +Translated:Point 7 + +English:Point 8 +Translated:Point 8 + +English:Point 9 +Translated:Point 9 + English:Point Size Translated:Point Size diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 7ed8dca97..00b99afed 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 7ed8dca97eab5e850a0031b71cea55c19b826f39 +Subproject commit 00b99afed26b58d9c3a25eafa891fcef0dfd89de diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 997d76189..c19b0609c 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 997d761896c03f40be9b7db8bd5ababd97a7c5ef +Subproject commit c19b0609c41c64e5eb90961cd80b211abc08c0d9