From 90452dfc539c8f36daf4516a4edd162470c9d899 Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Sun, 11 Apr 2021 19:15:51 -0700 Subject: [PATCH] Finished a scale matrix edge control --- .../ScaleControls/ScaleHeightControl.cs | 5 +++-- ...Control.cs => ScaleMatrixCornerControl.cs} | 6 ++--- ...geControl.cs => ScaleMatrixEdgeControl.cs} | 6 ++--- .../ScaleControls/ScaleMatrixTopControl.cs | 4 ++-- .../DesignTools/Primitives/PyramidObject3D.cs | 6 ++--- .../View3D/Object3DControlsLayer.cs | 22 ++++++++----------- Submodules/agg-sharp | 2 +- 7 files changed, 24 insertions(+), 27 deletions(-) rename MatterControlLib/DesignTools/EditorTools/ScaleControls/{ScaleCornerControl.cs => ScaleMatrixCornerControl.cs} (98%) rename MatterControlLib/DesignTools/EditorTools/ScaleControls/{ScaleEdgeControl.cs => ScaleMatrixEdgeControl.cs} (98%) diff --git a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleHeightControl.cs b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleHeightControl.cs index dc5dd98f3..0c2182a04 100644 --- a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleHeightControl.cs +++ b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleHeightControl.cs @@ -289,6 +289,9 @@ namespace MatterHackers.Plugins.EditorTools selectedItem.Invalidate(new InvalidateArgs(selectedItem, InvalidateType.DisplayValues)); } + var startMatrix = selectedItem.Matrix; + selectedItem.Matrix = startMatrix; + await selectedItem.Rebuild(); var postScaleBottom = GetBottomPosition(selectedItem); @@ -354,8 +357,6 @@ namespace MatterHackers.Plugins.EditorTools public override void SetPosition(IObject3D selectedItem, MeshSelectInfo selectInfo) { - AxisAlignedBoundingBox selectedBounds = selectedItem.GetAxisAlignedBoundingBox(); - var topPosition = GetTopPosition(selectedItem); double distBetweenPixelsWorldSpace = Object3DControlContext.World.GetWorldUnitsPerScreenPixelAtPosition(topPosition); diff --git a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleCornerControl.cs b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleMatrixCornerControl.cs similarity index 98% rename from MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleCornerControl.cs rename to MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleMatrixCornerControl.cs index 4bdb7b8ec..b95e5ff09 100644 --- a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleCornerControl.cs +++ b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleMatrixCornerControl.cs @@ -45,7 +45,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.Plugins.EditorTools { - public class ScaleCornerControl : Object3DControl + public class ScaleMatrixCornerControl : Object3DControl { public IObject3D ActiveSelectedItem { get; set; } @@ -69,7 +69,7 @@ namespace MatterHackers.Plugins.EditorTools private readonly InlineEditControl yValueDisplayInfo; private bool hadClickOnControl; - public ScaleCornerControl(IObject3DControlContext context, int cornerIndex) + public ScaleMatrixCornerControl(IObject3DControlContext context, int cornerIndex) : base(context) { theme = MatterControl.AppContext.Theme; @@ -160,7 +160,7 @@ namespace MatterHackers.Plugins.EditorTools { bool shouldDrawScaleControls = true; if (Object3DControlContext.SelectedObject3DControl != null - && Object3DControlContext.SelectedObject3DControl as ScaleCornerControl == null) + && Object3DControlContext.SelectedObject3DControl as ScaleMatrixCornerControl == null) { shouldDrawScaleControls = false; } diff --git a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleEdgeControl.cs b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleMatrixEdgeControl.cs similarity index 98% rename from MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleEdgeControl.cs rename to MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleMatrixEdgeControl.cs index dfc1eba13..b2ed8f068 100644 --- a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleEdgeControl.cs +++ b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleMatrixEdgeControl.cs @@ -45,7 +45,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.Plugins.EditorTools { - public class ScaleEdgeControl : Object3DControl + public class ScaleMatrixEdgeControl : Object3DControl { public IObject3D ActiveSelectedItem { get; set; } @@ -73,7 +73,7 @@ namespace MatterHackers.Plugins.EditorTools private readonly InlineEditControl yValueDisplayInfo; private bool hadClickOnControl; - public ScaleEdgeControl(IObject3DControlContext context, int edgeIndex) + public ScaleMatrixEdgeControl(IObject3DControlContext context, int edgeIndex) : base(context) { theme = MatterControl.AppContext.Theme; @@ -170,7 +170,7 @@ namespace MatterHackers.Plugins.EditorTools { bool shouldDrawScaleControls = true; if (Object3DControlContext.SelectedObject3DControl != null - && Object3DControlContext.SelectedObject3DControl as ScaleEdgeControl == null) + && Object3DControlContext.SelectedObject3DControl as ScaleMatrixEdgeControl == null) { shouldDrawScaleControls = false; } diff --git a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleMatrixTopControl.cs b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleMatrixTopControl.cs index 0cea28cc4..032133104 100644 --- a/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleMatrixTopControl.cs +++ b/MatterControlLib/DesignTools/EditorTools/ScaleControls/ScaleMatrixTopControl.cs @@ -116,7 +116,7 @@ namespace MatterHackers.Plugins.EditorTools Vector3 newSize = Vector3.Zero; newSize.Z = zValueDisplayInfo.Value; - Vector3 scaleAmount = ScaleCornerControl.GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, Object3DControlContext.GuiSurface.ModifierKeys); + Vector3 scaleAmount = ScaleMatrixCornerControl.GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, Object3DControlContext.GuiSurface.ModifierKeys); var scale = Matrix4X4.CreateScale(scaleAmount); @@ -275,7 +275,7 @@ namespace MatterHackers.Plugins.EditorTools newSize.Z = newPosition.Z - lockedBottom.Z; // scale it - Vector3 scaleAmount = ScaleCornerControl.GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, Object3DControlContext.GuiSurface.ModifierKeys); + Vector3 scaleAmount = ScaleMatrixCornerControl.GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, Object3DControlContext.GuiSurface.ModifierKeys); var scale = Matrix4X4.CreateScale(scaleAmount); diff --git a/MatterControlLib/DesignTools/Primitives/PyramidObject3D.cs b/MatterControlLib/DesignTools/Primitives/PyramidObject3D.cs index 3d5363b7d..bf0c01680 100644 --- a/MatterControlLib/DesignTools/Primitives/PyramidObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/PyramidObject3D.cs @@ -80,11 +80,11 @@ namespace MatterHackers.MatterControl.DesignTools { var path = new VertexStorage(); path.MoveTo(0, 0); - path.LineTo(Math.Sqrt(2), 0); - path.LineTo(0, Height); + path.LineTo(Math.Sqrt(2) * 100, 0); + path.LineTo(0, Height * 100); var mesh = VertexSourceToMesh.Revolve(path, 4); - mesh.Transform(Matrix4X4.CreateRotationZ(MathHelper.DegreesToRadians(45)) * Matrix4X4.CreateScale(Width / 2, Depth / 2, 1)); + mesh.Transform(Matrix4X4.CreateRotationZ(MathHelper.DegreesToRadians(45)) * Matrix4X4.CreateScale(Width / 2 / 100.0, Depth / 2 / 100.0, 1 / 100.0)); Mesh = mesh; } } diff --git a/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs b/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs index a44c9332e..ce7b2f35e 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs @@ -181,11 +181,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (selectedItem is IObjectWithHeight heightObject) { // When this is ready make the debug behavior the only behavior -#if DEBUG Object3DControls.Add(new ScaleHeightControl(this)); -#else - Object3DControls.Add(new ScaleMatrixTopControl(this)); -#endif } else { @@ -196,7 +192,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { #if DEBUG //Object3DControls.Add(new ScaleCornerControl(this, 0)); - Object3DControls.Add(new ScaleEdgeControl(this, 0)); + Object3DControls.Add(new ScaleMatrixEdgeControl(this, 0)); #else AddControls(ControlTypes.ScaleMatrixXY); #endif @@ -240,15 +236,15 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (controls.HasFlag(ControlTypes.ScaleMatrixXY)) { - Object3DControls.Add(new ScaleCornerControl(this, 0)); - Object3DControls.Add(new ScaleCornerControl(this, 1)); - Object3DControls.Add(new ScaleCornerControl(this, 2)); - Object3DControls.Add(new ScaleCornerControl(this, 3)); + Object3DControls.Add(new ScaleMatrixCornerControl(this, 0)); + Object3DControls.Add(new ScaleMatrixCornerControl(this, 1)); + Object3DControls.Add(new ScaleMatrixCornerControl(this, 2)); + Object3DControls.Add(new ScaleMatrixCornerControl(this, 3)); - Object3DControls.Add(new ScaleEdgeControl(this, 0)); - Object3DControls.Add(new ScaleEdgeControl(this, 1)); - Object3DControls.Add(new ScaleEdgeControl(this, 2)); - Object3DControls.Add(new ScaleEdgeControl(this, 3)); + Object3DControls.Add(new ScaleMatrixEdgeControl(this, 0)); + Object3DControls.Add(new ScaleMatrixEdgeControl(this, 1)); + Object3DControls.Add(new ScaleMatrixEdgeControl(this, 2)); + Object3DControls.Add(new ScaleMatrixEdgeControl(this, 3)); } if (controls.HasFlag(ControlTypes.Shadow)) diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 21228a0b3..162a2cbe5 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 21228a0b38ffbcdc9178cdf664820acd25ee7a3d +Subproject commit 162a2cbe5376307e7b7c4ef6278a5c3b39820349