Adding Chinese and Japanese support
Made twist object have support for rotation distance and a base that specifies radius (gears)
This commit is contained in:
parent
e659a372bb
commit
5556a746e9
7 changed files with 106 additions and 23 deletions
|
|
@ -90,6 +90,7 @@ namespace MatterHackers.MatterControl
|
|||
Bangers,
|
||||
Courgette,
|
||||
Damion,
|
||||
Firefly_Sung,
|
||||
Fredoka,
|
||||
Great_Vibes,
|
||||
Liberation_Mono,
|
||||
|
|
@ -2883,6 +2884,23 @@ namespace MatterHackers.MatterControl
|
|||
Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName.ToLower() :
|
||||
UserSettings.Instance.Language.ToLower();
|
||||
|
||||
if (twoLetterIsoLanguageName == "ja"
|
||||
|| twoLetterIsoLanguageName == "zh")
|
||||
{
|
||||
AggContext.DefaultFont = ApplicationController.GetTypeFace(NamedTypeFace.Firefly_Sung);
|
||||
AggContext.DefaultFontBold = ApplicationController.GetTypeFace(NamedTypeFace.Firefly_Sung);
|
||||
AggContext.DefaultFontItalic = ApplicationController.GetTypeFace(NamedTypeFace.Firefly_Sung);
|
||||
AggContext.DefaultFontBoldItalic = ApplicationController.GetTypeFace(NamedTypeFace.Firefly_Sung);
|
||||
}
|
||||
else
|
||||
{
|
||||
AggContext.DefaultFont = LiberationSansFont.Instance;
|
||||
AggContext.DefaultFontBold = LiberationSansBoldFont.Instance;
|
||||
AggContext.DefaultFontItalic = LiberationSansFont.Instance;
|
||||
AggContext.DefaultFontBoldItalic = LiberationSansBoldFont.Instance;
|
||||
}
|
||||
|
||||
|
||||
string translationFilePath = Path.Combine("Translations", twoLetterIsoLanguageName, "Translation.txt");
|
||||
|
||||
if (twoLetterIsoLanguageName == "en")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.Font;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
|
|
@ -14,7 +17,6 @@ namespace MatterHackers.MatterControl
|
|||
this.MinimumSize = new Vector2(this.LocalBounds.Width, this.LocalBounds.Height);
|
||||
CreateLanguageDict();
|
||||
|
||||
|
||||
foreach (KeyValuePair<string, string> entry in languageDict)
|
||||
{
|
||||
AddItem(entry.Key, entry.Value);
|
||||
|
|
@ -38,12 +40,14 @@ namespace MatterHackers.MatterControl
|
|||
["Default"] = "EN",
|
||||
["English"] = "EN",
|
||||
["Čeština"] = "CS",
|
||||
["Chinese "] = "ZH",
|
||||
["Dansk"] = "DA",
|
||||
["Deutsch"] = "DE",
|
||||
["Español"] = "ES",
|
||||
["ελληνικά"] = "EL",
|
||||
["Français"] = "FR",
|
||||
["Italiano"] = "IT",
|
||||
["Japanese"] = "JA",
|
||||
["Norsk"] = "NO",
|
||||
["Polski"] = "PL",
|
||||
//["Português"] = "CR",
|
||||
|
|
|
|||
|
|
@ -56,6 +56,22 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
Name = "Twist".Localize();
|
||||
}
|
||||
|
||||
public enum RotationTypes
|
||||
{
|
||||
Angle,
|
||||
Distance
|
||||
}
|
||||
|
||||
[EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Tabs)]
|
||||
public RotationTypes RotationType { get; set; } = RotationTypes.Angle;
|
||||
|
||||
[Description("The distance along the circumference to rotate the top in mm")]
|
||||
public double RotationDistance { get; set; } = 10;
|
||||
|
||||
[Description("Specifies the number of vertical cuts to make for the twist")]
|
||||
[Range(3, 300, ErrorMessage = "Value for {0} must be between {1} and {2}.")]
|
||||
public double NumberOfVerticalCuts { get; set; } = 5;
|
||||
|
||||
[Description("The angle to rotate the top of the part")]
|
||||
public double Angle { get; set; } = 135;
|
||||
|
||||
|
|
@ -66,11 +82,11 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
[DisplayName("Twist Right")]
|
||||
public bool TwistCw { get; set; } = true;
|
||||
|
||||
public bool Advanced { get; set; }
|
||||
|
||||
[Description("Allows for the repositioning of the rotation origin")]
|
||||
public Vector2 RotationOffset { get; set; }
|
||||
|
||||
public bool Advanced { get; set; }
|
||||
|
||||
public Easing.EaseType EasingType { get; set; } = Easing.EaseType.Linear;
|
||||
|
||||
public Easing.EaseOption EasingOption { get; set; } = Easing.EaseOption.InOut;
|
||||
|
|
@ -111,6 +127,18 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
valuesChanged = true;
|
||||
}
|
||||
|
||||
if (RotationDistance < 0 || RotationDistance > 100000)
|
||||
{
|
||||
RotationDistance = Math.Min(100000, Math.Max(0, RotationDistance));
|
||||
valuesChanged = true;
|
||||
}
|
||||
|
||||
if (NumberOfVerticalCuts < 3 || NumberOfVerticalCuts > 300)
|
||||
{
|
||||
NumberOfVerticalCuts = Math.Min(300, Math.Max(3, NumberOfVerticalCuts));
|
||||
valuesChanged = true;
|
||||
}
|
||||
|
||||
if (EndHeightPercent < 1 || EndHeightPercent > 100)
|
||||
{
|
||||
EndHeightPercent = Math.Min(100, Math.Max(1, EndHeightPercent));
|
||||
|
|
@ -141,7 +169,12 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
size = top - bottom;
|
||||
}
|
||||
|
||||
double numberOfCuts = MinCutsPerRotation * (Angle / 360.0);
|
||||
double numberOfCuts = NumberOfVerticalCuts;
|
||||
if (RotationType == RotationTypes.Angle)
|
||||
{
|
||||
numberOfCuts = MinCutsPerRotation * (Angle / 360.0);
|
||||
}
|
||||
|
||||
double cutSize = size / numberOfCuts;
|
||||
var cuts = new List<double>();
|
||||
for (int i = 0; i < numberOfCuts + 1; i++)
|
||||
|
|
@ -175,7 +208,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
}
|
||||
|
||||
// get the rotation from the center of the circumscribed circle of the convex hull
|
||||
var rotationCenter = SourceContainer.GetSmallestEnclosingCircleAlongZ().Center + RotationOffset;
|
||||
var enclosingCircle = SourceContainer.GetSmallestEnclosingCircleAlongZ();
|
||||
var rotationCenter = enclosingCircle.Center + RotationOffset;
|
||||
|
||||
var twistedChildren = new List<IObject3D>();
|
||||
|
||||
|
|
@ -222,6 +256,19 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
}
|
||||
|
||||
var angleToRotate = ratio * Angle / 360.0 * MathHelper.Tau;
|
||||
if (RotationType == RotationTypes.Distance)
|
||||
{
|
||||
if (this.SourceContainer.Children.Count == 1
|
||||
&& this.SourceContainer.Children.First() is IRadiusProvider radiusProvider)
|
||||
{
|
||||
angleToRotate = ratio * (RotationDistance / radiusProvider.Radius);
|
||||
}
|
||||
else
|
||||
{
|
||||
// calculate the angle based on the distance we want to rotate
|
||||
angleToRotate = ratio * (RotationDistance / enclosingCircle.Radius);
|
||||
}
|
||||
}
|
||||
|
||||
if (!TwistCw)
|
||||
{
|
||||
|
|
@ -271,30 +318,41 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
});
|
||||
}
|
||||
|
||||
private Dictionary<string, bool> changeSet = new Dictionary<string, bool>();
|
||||
|
||||
public void UpdateControls(PublicPropertyChange change)
|
||||
{
|
||||
if (change.Context.GetEditRow(nameof(EndHeightPercent)) is GuiWidget widget)
|
||||
changeSet.Clear();
|
||||
|
||||
changeSet.Add(nameof(RotationDistance), RotationType == RotationTypes.Distance);
|
||||
changeSet.Add(nameof(NumberOfVerticalCuts), RotationType == RotationTypes.Distance);
|
||||
changeSet.Add(nameof(Angle), RotationType == RotationTypes.Angle);
|
||||
changeSet.Add(nameof(MinCutsPerRotation), RotationType == RotationTypes.Angle);
|
||||
changeSet.Add(nameof(RotationOffset), Advanced);
|
||||
changeSet.Add(nameof(StartHeightPercent), Advanced);
|
||||
changeSet.Add(nameof(EasingOption), Advanced && EasingType != Easing.EaseType.Linear);
|
||||
changeSet.Add(nameof(EasingType), Advanced);
|
||||
changeSet.Add(nameof(EndHeightPercent), Advanced);
|
||||
|
||||
// first turn on all the settings we want to see
|
||||
foreach (var kvp in changeSet.Where(c => c.Value))
|
||||
{
|
||||
widget.Visible = Advanced;
|
||||
change.SetRowVisible(kvp.Key, () => kvp.Value);
|
||||
}
|
||||
|
||||
if (change.Context.GetEditRow(nameof(StartHeightPercent)) is GuiWidget widget2)
|
||||
// then turn off all the settings we want to hide
|
||||
foreach (var kvp in changeSet.Where(c => !c.Value))
|
||||
{
|
||||
widget2.Visible = Advanced;
|
||||
}
|
||||
|
||||
if (change.Context.GetEditRow(nameof(EasingOption)) is GuiWidget widget3)
|
||||
{
|
||||
widget3.Visible = Advanced && EasingType != Easing.EaseType.Linear;
|
||||
}
|
||||
|
||||
if (change.Context.GetEditRow(nameof(EasingType)) is GuiWidget widget4)
|
||||
{
|
||||
widget4.Visible = Advanced;
|
||||
change.SetRowVisible(kvp.Key, () => kvp.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IRadiusProvider
|
||||
{
|
||||
double Radius { get; }
|
||||
}
|
||||
|
||||
public static class ObjectCircleExtensions
|
||||
{
|
||||
public static Circle GetSmallestEnclosingCircleAlongZ(this IObject3D object3D)
|
||||
|
|
|
|||
|
|
@ -353,9 +353,12 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, bool> changeSet = new Dictionary<string, bool>();
|
||||
|
||||
public void UpdateControls(PublicPropertyChange change)
|
||||
{
|
||||
var changeSet = new Dictionary<string, bool>();
|
||||
changeSet.Clear();
|
||||
|
||||
changeSet.Add(nameof(NoBaseMessage), BaseType == BaseTypes.None);
|
||||
changeSet.Add(nameof(SpaceHolder1), BaseType == BaseTypes.None || BaseType == BaseTypes.Rectangle);
|
||||
changeSet.Add(nameof(SpaceHolder2), BaseType == BaseTypes.None);
|
||||
|
|
|
|||
BIN
StaticData/Fonts/Firefly_Sung.ttf
Normal file
BIN
StaticData/Fonts/Firefly_Sung.ttf
Normal file
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
Subproject commit 3f519e7d4b9bed928ce3da186bbf7cbdd0245fde
|
||||
Subproject commit 924fcb33e812d9e2b3014bd00283d5c43045039e
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 929a7968c8099e1eea33f5128cb60701f0200eca
|
||||
Subproject commit 7b3fe724ccbb99c2b1bcd3effec6f18d0a18b62e
|
||||
Loading…
Add table
Add a link
Reference in a new issue