From b1202eab762fd324d06aa08893daa83ec1df94a5 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Mon, 12 Feb 2018 17:45:57 -0800 Subject: [PATCH] New align images Improved advanced array --- ApplicationView/ApplicationController.cs | 4 +- DesignTools/Operations/ArrangeObject3D.cs | 17 +++-- .../Operations/ArrayAdvancedObject3D.cs | 25 +++---- DesignTools/PublicPropertyEditor.cs | 67 +++++++++++++----- StaticData/Icons/align_to_bottom.png | Bin 0 -> 241 bytes StaticData/Icons/align_to_center_x.png | Bin 0 -> 255 bytes StaticData/Icons/align_to_center_y.png | Bin 0 -> 274 bytes StaticData/Icons/align_to_left.png | Bin 0 -> 234 bytes StaticData/Icons/align_to_right.png | Bin 0 -> 241 bytes StaticData/Icons/align_to_top.png | Bin 0 -> 257 bytes Submodules/agg-sharp | 2 +- 11 files changed, 74 insertions(+), 41 deletions(-) create mode 100644 StaticData/Icons/align_to_bottom.png create mode 100644 StaticData/Icons/align_to_center_x.png create mode 100644 StaticData/Icons/align_to_center_y.png create mode 100644 StaticData/Icons/align_to_left.png create mode 100644 StaticData/Icons/align_to_right.png create mode 100644 StaticData/Icons/align_to_top.png 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 0000000000000000000000000000000000000000..d87a997c2819a307ae4359c26381a1a7c183b571 GIT binary patch literal 241 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7*pj^6T^Rm@;DWu&Co?cG za29w(7BevL9RXp+soH$f3=9nHC7!;n?2nju8MX9pbunCGU|^{8ba4!^IGvoZK)^t$ zSTAmm219CHLPA2qid~9))3YyEXf`bQ!rXJPDeVEf$-nxTX%CGU)E&xrC#{y4p~1_% zDE7j#k3y@nHOdaIU<@%}P%W)}^t5&Po)ebaB{`S6R5*Q#``L7``YE@_$)}pD{%d-9 o1c*DHaT8e=4f#cd)KzU|?YIboFyt=akR{0H<+MWB>pF literal 0 HcmV?d00001 diff --git a/StaticData/Icons/align_to_center_x.png b/StaticData/Icons/align_to_center_x.png new file mode 100644 index 0000000000000000000000000000000000000000..ed03e10c8ecb0743ee1191f06d19c1a8221af05a GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7*pj^6T^Rm@;DWu&Co?cG za29w(7BevL9RXp+soH$f3=9nHC7!;n?2nju8CBI(&Mn!=z`)Ss>Eak-aXL9AAt7N$ z#YZLPoeiurgG-&~sGQA}(wCeep}}Gx&S79+P~%`GDeh3Nx>QeKL7(`lypH;WgoGdd zP6mNZLPElx`X?M-Iy(M=sU35Qr5}ptXbP^9e3w2$vCGV? z;NWlfz5{y|3=$F@#6HCRY&ux|w41Sn(TIT|bBXE_=cc!37#J8BJYD@<);T3K0RT#+ BQ*rgTe~DWM4fU{hnl literal 0 HcmV?d00001 diff --git a/StaticData/Icons/align_to_left.png b/StaticData/Icons/align_to_left.png new file mode 100644 index 0000000000000000000000000000000000000000..3632277cfe11acaea58702adf5d761d3c222014a GIT binary patch literal 234 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7*pj^6T^Rm@;DWu&Co?cG za29w(7BevL9RXp+soH$f3=9nHC7!;n?2nju8I?7r>gZW8Fff#Rx;TbdoKD_T@llC+ zr$c=F{KnSC#>R!O+AKV!Zkxm%y6M9s!X#F+Y%#ORbS?t}gPMdUqZ4c)Uk}wMF^jBf zo2aF?V4nE2}~fdI7~H20D%v2KbsC#KkaVp dWbI;PP%DzjyqWTdn}LCW!PC{xWt~$(69CbOO;Z2> literal 0 HcmV?d00001 diff --git a/StaticData/Icons/align_to_right.png b/StaticData/Icons/align_to_right.png new file mode 100644 index 0000000000000000000000000000000000000000..a100508c2de9ad32292fef443fc5d996d17588c9 GIT binary patch literal 241 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7*pj^6T^Rm@;DWu&Co?cG za29w(7BevL9RXp+soH$f3=9nHC7!;n?2nju8C5tQGS4t)U|^{8ba4!^IGvo5kdUyW z;-eDt&IZ<*!KKb~RL2c_*nah|vb)6036~BYXkm;z nQ2msf?fq1JwhOE$7#NJqbP0l+XkK%S}yZ literal 0 HcmV?d00001 diff --git a/StaticData/Icons/align_to_top.png b/StaticData/Icons/align_to_top.png new file mode 100644 index 0000000000000000000000000000000000000000..a51a4e42b829d16bfd2c082a8bd2121b90c44d9e GIT binary patch literal 257 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7*pj^6T^Rm@;DWu&Co?cG za29w(7BevL9RXp+soH$f3=9nHC7!;n?2nju8MQ>R8()57U|{I;ba4!^IGvp0z$C68 z=kkopAc0+ef~5`*4-d~h?RWza(73hYU%RKvxt(WEI52F<+>?@UNOh-;>sNbbW@e*f zToDoy5)#|myd5g`?BU7K`{92=ROiH;-|l?}=H5N_Vba1^Z5Ca{i42i*Ivbq~vKT~p z5){J}i>~nYa8D2xvSVhsP$Z+=cjsqgV-y2}yR5?9AG_qz85kHCJYD@<);T3K0RRVg BQvUz| literal 0 HcmV?d00001 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