diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index f6e88aae1..178a497dd 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -436,9 +436,9 @@ namespace MatterHackers.MatterControl Action = (scene) => { scene.AddSelectionAsChildren(new ArrangeObject3D()); - if(scene.SelectedItem is ArrangeObject3D arrange) + if(scene.SelectedItem is ArrangeObject3D arange) { - arrange.Rebuild(); + arange.Rebuild(); } }, //Icon = AggContext.StaticData.LoadIcon("array_linear.png").SetPreMultiply(), diff --git a/DesignTools/Operations/ArrangeObject3D.cs b/DesignTools/Operations/ArrangeObject3D.cs index 00bdb6b79..d88a04f55 100644 --- a/DesignTools/Operations/ArrangeObject3D.cs +++ b/DesignTools/Operations/ArrangeObject3D.cs @@ -50,22 +50,31 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public override string ActiveEditor => "PublicPropertyEditor"; - [Icons(new string[] {"align_left.png", "align_center_x.png", "align_right.png"})] + [Icons(new string[] {"424.png", "align_left.png", "align_center_x.png", "align_right.png"})] public Align XAlign { get; set; } = Align.None; - [Icons(new string[] { "align_left.png", "align_center_x.png", "align_right.png" })] - [EnableIf("XAlign", "!None")] + [Icons(new string[] { "424.png", "align_to_left.png", "align_to_center_x.png", "align_to_right.png" })] + [EnableIf("Advanced", "true")] public Align XAlignTo { get; set; } = Align.None; - [EnableIf("XAlign", "!None")] + [EnableIf("Advanced", "true")] public double OffsetX { get; set; } = 0; + [Icons(new string[] { "424.png", "align_bottom.png", "align_center_y.png", "align_top.png" })] public Align YAlign { get; set; } = Align.None; + [Icons(new string[] { "424.png", "align_to_bottom.png", "align_to_center_y.png", "align_to_top.png" })] + [EnableIf("Advanced", "true")] public Align YAlignTo { get; set; } = Align.None; + [EnableIf("Advanced", "true")] public double YOffset { get; set; } = 0; + [Icons(new string[] { "424.png", "align_bottom.png", "align_center_y.png", "align_top.png" })] public Align ZAlign { get; set; } = Align.None; + [Icons(new string[] { "424.png", "align_to_bottom.png", "align_to_center_y.png", "align_to_top.png" })] + [EnableIf("Advanced", "true")] public Align ZAlignTo { get; set; } = Align.None; + [EnableIf("Advanced", "true")] public double ZOffset { get; set; } = 0; + public bool Advanced { get; set; } = false; public void Rebuild() { diff --git a/DesignTools/Operations/ArrayAdvancedObject3D.cs b/DesignTools/Operations/ArrayAdvancedObject3D.cs index df6602fda..aee9af179 100644 --- a/DesignTools/Operations/ArrayAdvancedObject3D.cs +++ b/DesignTools/Operations/ArrayAdvancedObject3D.cs @@ -41,12 +41,11 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public override string ActiveEditor => "PublicPropertyEditor"; public int Count { get; set; } = 3; - public double Rotate { get; set; } = 0; - public bool RotatePart { get; set; } = false; + public Vector3 Offset { get; set; } = new Vector3(30, 0, 0); + public Vector3 Rotate { get; set; } = Vector3.Zero; public double Scale { get; set; } = 1; - public bool ScaleOffset { get; set; } = false; - public double XOffset { get; set; } = 30; - public double YOffset { get; set; } = 0; + public bool RotatePart { get; set; } = true; + public bool ScaleOffset { get; set; } = true; public void Rebuild() { @@ -55,26 +54,22 @@ namespace MatterHackers.MatterControl.DesignTools.Operations IObject3D lastChild = list.First(); list.Clear(); list.Add(lastChild); - var offset = Vector3.Zero; + var offset = Offset; for (int i = 1; i < Count; i++) { - var rotateRadians = MathHelper.DegreesToRadians(Rotate); - var nextOffset = new Vector2(XOffset, YOffset); + var rotateRadians = new Vector3(MathHelper.DegreesToRadians(Rotate.X), MathHelper.DegreesToRadians(Rotate.Y), MathHelper.DegreesToRadians(Rotate.Z)); if (ScaleOffset) { - for (int j = 1; j < i; j++) - { - nextOffset *= Scale; - } + offset *= Scale; } - nextOffset.Rotate(rotateRadians * i); + offset = Vector3.Transform(offset, Matrix4X4.CreateRotation(rotateRadians * i)); var next = lastChild.Clone(); - next.Matrix *= Matrix4X4.CreateTranslation(nextOffset.X, nextOffset.Y, 0); + next.Matrix *= Matrix4X4.CreateTranslation(offset); if (RotatePart) { - next.ApplyAtBoundsCenter(Matrix4X4.CreateRotationZ(rotateRadians)); + next.ApplyAtBoundsCenter(Matrix4X4.CreateRotation(rotateRadians)); } next.ApplyAtBoundsCenter(Matrix4X4.CreateScale(Scale)); diff --git a/DesignTools/PublicPropertyEditor.cs b/DesignTools/PublicPropertyEditor.cs index 2cb8423d9..9772c3d1c 100644 --- a/DesignTools/PublicPropertyEditor.cs +++ b/DesignTools/PublicPropertyEditor.cs @@ -33,6 +33,7 @@ using System.ComponentModel; using System.Linq; using System.Reflection; using MatterHackers.Agg; +using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; @@ -86,7 +87,9 @@ namespace MatterHackers.MatterControl.DesignTools private static Type[] allowedTypes = { - typeof(double), typeof(int), typeof(string), typeof(bool), typeof(DirectionVector), typeof(DirectionAxis) + typeof(double), typeof(int), typeof(string), typeof(bool), + typeof(Vector2), typeof(Vector3), + typeof(DirectionVector), typeof(DirectionAxis) }; public const BindingFlags OwnedPropertiesOnly = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; @@ -399,27 +402,53 @@ namespace MatterHackers.MatterControl.DesignTools FlowLayoutWidget rowContainer = CreateSettingsRow(displayName); - var dropDownList = new DropDownList("Name".Localize(), theme.Colors.PrimaryTextColor, Direction.Down, pointSize: theme.DefaultFontSize); - - var sortableAttribute = propertyInfo.GetCustomAttributes(true).OfType().FirstOrDefault(); - var orderedItems = sortableAttribute != null ? enumItems.OrderBy(n => n.Value) : enumItems; - - foreach (var orderItem in orderedItems) + var iconsAttribute = propertyInfo.GetCustomAttributes(true).OfType().FirstOrDefault(); + if (iconsAttribute != null) { - MenuItem newItem = dropDownList.AddItem(orderItem.Value); - - var localOredrItem = orderItem; - newItem.Selected += (sender, e) => + int index = 0; + foreach (var enumItem in enumItems) { - propertyInfo.GetSetMethod().Invoke( - this.item, - new Object[] { Enum.Parse(propertyType, localOredrItem.Key) }); - item?.Rebuild(); - }; - } + var iconImage = AggContext.StaticData.LoadIcon(iconsAttribute.IconPaths[index++], 16, 16); + var radioButton = new RadioButton(new ImageWidget(iconImage)); + rowContainer.AddChild(radioButton); - dropDownList.SelectedLabel = value.ToString().Replace('_', ' '); - rowContainer.AddChild(dropDownList); + var localItem = enumItem; + radioButton.CheckedStateChanged += (sender, e) => + { + if (radioButton.Checked) + { + propertyInfo.GetSetMethod().Invoke( + this.item, + new Object[] { Enum.Parse(propertyType, localItem.Key) }); + item?.Rebuild(); + } + }; + } + } + else + { + var dropDownList = new DropDownList("Name".Localize(), theme.Colors.PrimaryTextColor, Direction.Down, pointSize: theme.DefaultFontSize); + + var sortableAttribute = propertyInfo.GetCustomAttributes(true).OfType().FirstOrDefault(); + var orderedItems = sortableAttribute != null ? enumItems.OrderBy(n => n.Value) : enumItems; + + foreach (var orderItem in orderedItems) + { + MenuItem newItem = dropDownList.AddItem(orderItem.Value); + + var localOredrItem = orderItem; + newItem.Selected += (sender, e) => + { + propertyInfo.GetSetMethod().Invoke( + this.item, + new Object[] { Enum.Parse(propertyType, localOredrItem.Key) }); + item?.Rebuild(); + }; + } + + dropDownList.SelectedLabel = value.ToString().Replace('_', ' '); + rowContainer.AddChild(dropDownList); + } return rowContainer; } diff --git a/StaticData/Icons/align_to_bottom.png b/StaticData/Icons/align_to_bottom.png new file mode 100644 index 000000000..d87a997c2 Binary files /dev/null and b/StaticData/Icons/align_to_bottom.png differ diff --git a/StaticData/Icons/align_to_center_x.png b/StaticData/Icons/align_to_center_x.png new file mode 100644 index 000000000..ed03e10c8 Binary files /dev/null and b/StaticData/Icons/align_to_center_x.png differ diff --git a/StaticData/Icons/align_to_center_y.png b/StaticData/Icons/align_to_center_y.png new file mode 100644 index 000000000..629e18fdd Binary files /dev/null and b/StaticData/Icons/align_to_center_y.png differ diff --git a/StaticData/Icons/align_to_left.png b/StaticData/Icons/align_to_left.png new file mode 100644 index 000000000..3632277cf Binary files /dev/null and b/StaticData/Icons/align_to_left.png differ diff --git a/StaticData/Icons/align_to_right.png b/StaticData/Icons/align_to_right.png new file mode 100644 index 000000000..a100508c2 Binary files /dev/null and b/StaticData/Icons/align_to_right.png differ diff --git a/StaticData/Icons/align_to_top.png b/StaticData/Icons/align_to_top.png new file mode 100644 index 000000000..a51a4e42b Binary files /dev/null and b/StaticData/Icons/align_to_top.png differ diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 515eaedcb..275a3e2c8 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 515eaedcb719f41e4127f566b7bdf5c3c222cf6d +Subproject commit 275a3e2c8c5e6391e4e649a0794754f7da7e0281