New align images

Improved advanced array
This commit is contained in:
Lars Brubaker 2018-02-12 17:45:57 -08:00
parent 79cd879e56
commit b1202eab76
11 changed files with 74 additions and 41 deletions

View file

@ -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(),

View file

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

View file

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

View file

@ -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<SortableAttribute>().FirstOrDefault();
var orderedItems = sortableAttribute != null ? enumItems.OrderBy(n => n.Value) : enumItems;
foreach (var orderItem in orderedItems)
var iconsAttribute = propertyInfo.GetCustomAttributes(true).OfType<IconsAttribute>().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<SortableAttribute>().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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

@ -1 +1 @@
Subproject commit 515eaedcb719f41e4127f566b7bdf5c3c222cf6d
Subproject commit 275a3e2c8c5e6391e4e649a0794754f7da7e0281