From dff1d75244139a9835c6b0a0c07cb59d445163ea Mon Sep 17 00:00:00 2001 From: FoggyFinder Date: Thu, 24 Oct 2019 17:54:16 +0300 Subject: [PATCH 1/5] skip scripted displays when calculate Range.End --- CSharpMath/Display/MathListDisplay.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CSharpMath/Display/MathListDisplay.cs b/CSharpMath/Display/MathListDisplay.cs index 4b96c9685..53c0be871 100644 --- a/CSharpMath/Display/MathListDisplay.cs +++ b/CSharpMath/Display/MathListDisplay.cs @@ -37,7 +37,11 @@ public ListDisplay(IReadOnlyList> displays) { public float Descent => Displays.CollectionDescent(); public PointF Position { get; set; } public RectangleF DisplayBounds => this.ComputeDisplayBounds(); - public Range Range => Range.Combine(Displays.Select(d => d.Range)); + public Range Range => + Range.Combine( + Displays + .Where(d => !(d is ListDisplay ld && ld.LinePosition != Enumerations.LinePosition.Regular)) + .Select(d => d.Range)); public float Width => Displays.CollectionMaxX() - Displays.CollectionX(); public void Draw(IGraphicsContext context) { context.SaveState(); From c50cb784e94017405418d2ee20967902054caf98 Mon Sep 17 00:00:00 2001 From: FoggyFinder Date: Thu, 24 Oct 2019 22:49:07 +0300 Subject: [PATCH 2/5] remove some outdated parts --- .../DisplayEditingExtensions.List.cs | 58 ++++++------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/CSharpMath.Editor/Extensions/DisplayEditingExtensions.List.cs b/CSharpMath.Editor/Extensions/DisplayEditingExtensions.List.cs index d83af073c..94c7bca50 100644 --- a/CSharpMath.Editor/Extensions/DisplayEditingExtensions.List.cs +++ b/CSharpMath.Editor/Extensions/DisplayEditingExtensions.List.cs @@ -90,46 +90,26 @@ public static MathListIndex IndexForPoint(this ListDisplay(this ListDisplay self, TypesettingContext context, MathListIndex index) where TFont : IFont { if (index is null) return null; - PointF? position = null; - var nonScripted = - self.Displays - .Where(d => !(d is ListDisplay ld && - ld.LinePosition != Enumerations.LinePosition.Regular)) - .ToArray(); - if (index.SubIndexType == MathListSubIndexType.None && - nonScripted.Length > 0 && - nonScripted.All(d => d.Range.End <= index.AtomIndex)) { + PointF? position; + if (index.AtomIndex == self.Range.End) { + // Special case the edge of the range position = new PointF(self.Width, 0); - } else { - if (index.AtomIndex == self.Range.End) { - // Special case the edge of the range - position = new PointF(self.Width, 0); - } else if (self.Range.Contains(index.AtomIndex) && self.SubDisplayForIndex(index) is IDisplay display) - switch (index.SubIndexType) { - case MathListSubIndexType.BetweenBaseAndScripts: - var nucleusPosition = index.AtomIndex + index.SubIndex.AtomIndex; - position = display.PointForIndex(context, MathListIndex.Level0Index(nucleusPosition)); - break; - case MathListSubIndexType.None: - if (!display.HasScript) { - position = display.PointForIndex(context, index); - } else { - var mainPosition = display.PointForIndex(context, index); - position = self.Displays.SingleOrDefault(d => - d is ListDisplay ld && ld.IndexInParent == index.AtomIndex - 1) - is IDisplay scripted && mainPosition != null - ? new PointF(mainPosition.Value.X + scripted.Width, 0) - : mainPosition; - } - break; - default: - // Recurse - position = display.PointForIndex(context, index.SubIndex); - break; - } else - // Outside the range - return null; - } + } else if (self.Range.Contains(index.AtomIndex) && self.SubDisplayForIndex(index) is IDisplay display) + switch (index.SubIndexType) { + case MathListSubIndexType.BetweenBaseAndScripts: + var nucleusPosition = index.AtomIndex + index.SubIndex.AtomIndex; + position = display.PointForIndex(context, MathListIndex.Level0Index(nucleusPosition)); + break; + case MathListSubIndexType.None: + position = display.PointForIndex(context, index); + break; + default: + // Recurse + position = display.PointForIndex(context, index.SubIndex); + break; + } else + // Outside the range + return null; if (position is PointF found) { // Convert bounds from our coordinate system before returning found.X += self.Position.X; From 2926b800c14527f83c0a25301ba75f7a9091ec9d Mon Sep 17 00:00:00 2001 From: FoggyFinder Date: Fri, 25 Oct 2019 11:20:50 +0300 Subject: [PATCH 3/5] add test for issue64 --- CSharpMath.Editor.Tests/IndexForPointTests.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CSharpMath.Editor.Tests/IndexForPointTests.cs b/CSharpMath.Editor.Tests/IndexForPointTests.cs index 19f3fd011..e876fb189 100644 --- a/CSharpMath.Editor.Tests/IndexForPointTests.cs +++ b/CSharpMath.Editor.Tests/IndexForPointTests.cs @@ -490,5 +490,19 @@ public void Complex(PointF point, MathListIndex expected) => }; [Theory, MemberData(nameof(SineData))] public void Sine(PointF point, MathListIndex expected) => Test(@"\sin\pi", point, expected); + + public static TestData Issue64Data => + new TestData { + { (0, 15), 0 }, + { (10, 10), 0, (SubIndex.BetweenBaseAndScripts, 1) }, + { (10, 15), 0, (SubIndex.BetweenBaseAndScripts, 1) }, + { (12, 10), 0, (SubIndex.Superscript, 0) }, + { (12, 15), 0, (SubIndex.Superscript, 0) }, + { (35, 10), 1 }, + { (50, 15), 2 }, + }; + [Theory, MemberData(nameof(Issue64Data))] + public void Issue64(PointF point, MathListIndex expected) => Test(@"1^{123}+", point, expected); + } } \ No newline at end of file From f77cf958a2cc474aef503b540953aff072e7e35a Mon Sep 17 00:00:00 2001 From: FoggyFinder Date: Fri, 25 Oct 2019 14:30:34 +0300 Subject: [PATCH 4/5] update data for simple PointForIndex tests --- CSharpMath.Editor.Tests/IndexForPointTests.cs | 7 +- CSharpMath.Editor.Tests/PointForIndexTests.cs | 398 ++---------------- 2 files changed, 44 insertions(+), 361 deletions(-) diff --git a/CSharpMath.Editor.Tests/IndexForPointTests.cs b/CSharpMath.Editor.Tests/IndexForPointTests.cs index e876fb189..dc05c10e5 100644 --- a/CSharpMath.Editor.Tests/IndexForPointTests.cs +++ b/CSharpMath.Editor.Tests/IndexForPointTests.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; using System.Drawing; -using Xunit; -using CSharpMath; using CSharpMath.Atoms; -using CSharpMath.Editor; using CSharpMath.Enumerations; -using CSharpMath.FrontEnd; using CSharpMath.Tests.FrontEnd; +using Xunit; namespace CSharpMath.Editor.Tests { // Use the "CSharpMath.Editor Test Checker" project in the _Utils folder to visualize the test cases diff --git a/CSharpMath.Editor.Tests/PointForIndexTests.cs b/CSharpMath.Editor.Tests/PointForIndexTests.cs index 7830be23b..fb5e27119 100644 --- a/CSharpMath.Editor.Tests/PointForIndexTests.cs +++ b/CSharpMath.Editor.Tests/PointForIndexTests.cs @@ -1,122 +1,52 @@ -using System; -using System.Collections.Generic; using System.Drawing; -using Xunit; -using CSharpMath; -using CSharpMath.Atoms; -using CSharpMath.Editor; -using CSharpMath.Enumerations; -using CSharpMath.FrontEnd; using CSharpMath.Tests.FrontEnd; +using Xunit; namespace CSharpMath.Editor.Tests { + using static IndexForPointTests; // Use the "CSharpMath.Editor Test Checker" project in the _Utils folder to visualize the test cases using SubIndex = MathListSubIndexType; - using static IndexForPointTests; public class PointForIndexTests { - class TheoryAttribute : Xunit.TheoryAttribute { - public TheoryAttribute() : base() => Skip = "Needs updating test data"; - } void Test(string latex, PointF expected, MathListIndex index) { var display = CreateDisplay(latex); Assert.NotNull(display); - CSharpMath.Tests.Approximately.Equal(expected, display.PointForIndex(TestTypesettingContexts.Instance, index)); + var pr = display.PointForIndex(TestTypesettingContexts.Instance, index); + System.Diagnostics.Debug.WriteLine(pr); + CSharpMath.Tests.Approximately.Equal(expected, pr, 0.001); } public static TestData FractionData => new TestData { - { (-10, -20), 0 }, - { (-10, 0), 0 }, - { (-10, 8), 0 }, - { (-10, 40), 0 }, - { (-2.5, -20), 0 }, - { (-2.5, 0), 0 }, - { (-2.5, 8), 0 }, - { (-2.5, 40), 0 }, - { (-1, -20), 0, (SubIndex.Denominator, 0) }, - { (-1, 0), 0, (SubIndex.Denominator, 0) }, - { (-1, 8), 0, (SubIndex.Numerator, 0) }, - { (-1, 40), 0, (SubIndex.Numerator, 0) }, - { (3, -20), 0, (SubIndex.Denominator, 0) }, - { (3, 0), 0, (SubIndex.Denominator, 0) }, - { (3, 8), 0, (SubIndex.Numerator, 0) }, - { (3, 40), 0, (SubIndex.Numerator, 0) }, - { (7, -20), 0, (SubIndex.Denominator, 1) }, - { (7, 0), 0, (SubIndex.Denominator, 1) }, - { (7, 8), 0, (SubIndex.Numerator, 1) }, - { (7, 40), 0, (SubIndex.Numerator, 1) }, - { (11, -20), 1 }, // because it is below the height of the fraction - { (11, 0), 0, (SubIndex.Denominator, 1) }, - { (11, 8), 0, (SubIndex.Numerator, 1) }, - { (11, 40), 0, (SubIndex.Numerator, 1) }, - { (12.5, -20), 1 }, - { (12.5, 0), 1 }, - { (12.5, 8), 1 }, - { (12.5, 40), 1 }, - { (20, -20), 1 }, - { (20, 0), 1 }, - { (20, 8), 1 }, - { (20, 40), 1 }, - }; + { (0,0), 0 }, + { (0, -13.72), 0, (SubIndex.Denominator, 0) }, + { (0, 13.54), 0, (SubIndex.Numerator, 0) }, + { (10, -13.72), 0, (SubIndex.Denominator, 1) }, + { (10, 13.54), 0, (SubIndex.Numerator, 1) }, + { (10, 0), 1 }, + }; [Theory, MemberData(nameof(FractionData))] public void Fraction(PointF point, MathListIndex expected) => Test(@"\frac32", point, expected); public static TestData RegularData => new TestData { - { (-10, -20), 0 }, - { (-10, 0), 0 }, - { (-10, 8), 0 }, - { (-10, 40), 0 }, - { (0, -20), 0 }, { (0, 0), 0 }, - { (0, 8), 0 }, - { (0, 40), 0 }, - { (10, -20), 1 }, - { (10, 0), 1 }, - { (10, 8), 1 }, - { (10, 40), 1 }, - { (15, -20), 1 }, - { (15, 0), 1 }, - { (15, 8), 1 }, - { (15, 40), 1 }, - { (25, -20), 2 }, - { (25, 0), 2 }, - { (25, 8), 2 }, - { (25, 40), 2 }, - { (35, -20), 3 }, - { (35, 0), 3 }, - { (35, 8), 3 }, - { (35, 40), 3 }, - { (45, -20), 3 }, - { (45, 0), 3 }, - { (45, 8), 3 }, - { (45, 40), 3 }, - { (55, -20), 3 }, - { (55, 0), 3 }, - { (55, 8), 3 }, - { (55, 40), 3 }, + { (14.444, 0), 1 }, + { (28.888, 0), 2 }, + { (38.888, 0), 3 }, }; [Theory, MemberData(nameof(RegularData))] public void Regular(PointF point, MathListIndex expected) => Test(@"4+2", point, expected); public static TestData RegularPlusFractionData => new TestData { - { (26, -20), 2 }, - { (26, 0), 2 }, - { (26, 8), 2 }, - { (26, 40), 2 }, - { (28, -20), 2, (SubIndex.Denominator, 0) }, - { (28, 0), 2, (SubIndex.Denominator, 0) }, - { (28, 8), 2, (SubIndex.Numerator, 0) }, - { (28, 40), 2, (SubIndex.Numerator, 0) }, - { (33, -20), 2, (SubIndex.Denominator, 0) }, - { (33, 0), 2, (SubIndex.Denominator, 0) }, - { (33, 8), 2, (SubIndex.Numerator, 0) }, - { (33, 40), 2, (SubIndex.Numerator, 0) }, - { (35, -20), 2, (SubIndex.Denominator, 1) }, - { (35, 0), 2, (SubIndex.Denominator, 1) }, - { (35, 8), 2, (SubIndex.Numerator, 1) }, - { (35, 40), 2, (SubIndex.Numerator, 1) }, + { (0, 0), 0 }, + { (14.444, 0), 1 }, + { (28.888, 0), 2 }, + { (28.888, -13.72), 2, (SubIndex.Denominator, 0) }, + { (28.888, 13.54), 2, (SubIndex.Numerator, 0) }, + { (38.888, -13.72), 2, (SubIndex.Denominator, 1) }, + { (38.888, 13.54), 2, (SubIndex.Numerator, 1) }, + { (38.888, 0), 3 }, }; [Theory, MemberData(nameof(RegularPlusFractionData))] public void RegularPlusFraction(PointF point, MathListIndex expected) => @@ -124,22 +54,10 @@ public void RegularPlusFraction(PointF point, MathListIndex expected) => public static TestData FractionPlusRegularData => new TestData { - { (9, -20), 0, (SubIndex.Denominator, 1) }, - { (9, 0), 0, (SubIndex.Denominator, 1) }, - { (9, 8), 0, (SubIndex.Numerator, 1) }, - { (9, 40), 0, (SubIndex.Numerator, 1) }, - { (11, -20), 0, (SubIndex.Denominator, 1) }, - { (11, 0), 0, (SubIndex.Denominator, 1) }, - { (11, 8), 0, (SubIndex.Numerator, 1) }, - { (11, 40), 0, (SubIndex.Numerator, 1) }, - { (13, -20), 1 }, - { (13, 0), 1 }, - { (13, 8), 1 }, - { (13, 40), 1 }, - { (15, -20), 1 }, - { (15, 0), 1 }, - { (15, 8), 1 }, - { (15, 40), 1 }, + { (0,0), 0 }, + { (10, -13.72), 0, (SubIndex.Denominator, 1) }, + { (10, 13.54), 0, (SubIndex.Numerator, 1) }, + { (14.4444, 0), 1 }, }; [Theory, MemberData(nameof(FractionPlusRegularData))] public void FractionPlusRegular(PointF point, MathListIndex expected) => @@ -147,321 +65,91 @@ public void FractionPlusRegular(PointF point, MathListIndex expected) => public static TestData RadicalData => new TestData { - { (-3, -20), 0 }, - { (-3, 0), 0 }, - { (-3, 8), 0 }, - { (-3, 40), 0 }, - { (0, -20), 0 }, { (0, 0), 0 }, - { (0, 8), 0 }, - { (0, 40), 0, (SubIndex.Radicand, 0) }, - { (4, -20), 0 }, - { (4, 0), 0 }, - { (4, 8), 0, (SubIndex.Radicand, 0) }, - { (4, 40), 0, (SubIndex.Radicand, 0) }, - { (9, -20), 0, (SubIndex.Radicand, 0) }, - { (9, 0), 0, (SubIndex.Radicand, 0) }, - { (9, 8), 0, (SubIndex.Radicand, 0) }, - { (9, 40), 0, (SubIndex.Radicand, 0) }, - { (11, -20), 0, (SubIndex.Radicand, 0) }, - { (11, 0), 0, (SubIndex.Radicand, 0) }, - { (11, 8), 0, (SubIndex.Radicand, 0) }, - { (11, 40), 0, (SubIndex.Radicand, 0) }, - { (13, -20), 0, (SubIndex.Radicand, 0) }, - { (13, 0), 0, (SubIndex.Radicand, 0) }, - { (13, 8), 0, (SubIndex.Radicand, 0) }, - { (13, 40), 0, (SubIndex.Radicand, 0) }, - { (15, -20), 0, (SubIndex.Radicand, 1) }, - { (15, 0), 0, (SubIndex.Radicand, 1) }, - { (15, 8), 0, (SubIndex.Radicand, 1) }, - { (15, 40), 0, (SubIndex.Radicand, 1) }, - { (17, -20), 0, (SubIndex.Radicand, 1) }, - { (17, 0), 0, (SubIndex.Radicand, 1) }, - { (17, 8), 0, (SubIndex.Radicand, 1) }, - { (17, 40), 0, (SubIndex.Radicand, 1) }, - { (19, -20), 1 }, - { (19, 0), 0, (SubIndex.Radicand, 1) }, - { (19, 8), 0, (SubIndex.Radicand, 1) }, - { (19, 40), 0, (SubIndex.Radicand, 1) }, - { (21, -20), 1 }, - { (21, 0), 0, (SubIndex.Radicand, 1) }, - { (21, 8), 0, (SubIndex.Radicand, 1) }, - { (21, 40), 0, (SubIndex.Radicand, 1) }, - { (23, -20), 1 }, - { (23, 0), 1 }, - { (23, 8), 1 }, - { (23, 40), 1 }, - { (26, -20), 1 }, - { (26, 0), 1 }, - { (26, 8), 1 }, - { (26, 40), 1 }, - { (35, -20), 1 }, - { (35, 0), 1 }, - { (35, 8), 1 }, - { (35, 40), 1 }, + { (10, 0), 0, (SubIndex.Radicand, 0) }, + { (20, 0), 0, (SubIndex.Radicand, 1) }, }; [Theory, MemberData(nameof(RadicalData))] public void Radical(PointF point, MathListIndex expected) => Test(@"\sqrt2", point, expected); public static TestData RadicalDegreeData => new TestData { - { (-3, -20), 0 }, - { (-3, 0), 0 }, - { (-3, 8), 0 }, - { (-3, 40), 0 }, - { (0, -20), 0, (SubIndex.Radicand, 0) }, - { (0, 0), 0, (SubIndex.Radicand, 0) }, - { (0, 8), 0, (SubIndex.Degree, 0) }, - { (0, 40), 0, (SubIndex.Degree, 0) }, - { (4, -20), 0, (SubIndex.Radicand, 0) }, - { (4, 0), 0, (SubIndex.Radicand, 0) }, - { (4, 8), 0, (SubIndex.Degree, 0) }, - { (4, 40), 0, (SubIndex.Degree, 0) }, - { (9, -20), 0, (SubIndex.Radicand, 0) }, - { (9, 0), 0, (SubIndex.Radicand, 0) }, - { (9, 8), 0, (SubIndex.Degree, 0) }, - { (9, 40), 0, (SubIndex.Degree, 0) }, - { (11, -20), 0, (SubIndex.Radicand, 0) }, - { (11, 0), 0, (SubIndex.Radicand, 0) }, - { (11, 8), 0, (SubIndex.Radicand, 0) }, - { (11, 40), 0, (SubIndex.Degree, 1) }, - { (13, -20), 0, (SubIndex.Radicand, 0) }, - { (13, 0), 0, (SubIndex.Radicand, 0) }, - { (13, 8), 0, (SubIndex.Radicand, 0) }, - { (13, 40), 0, (SubIndex.Degree, 1) }, - { (15, -20), 0, (SubIndex.Radicand, 0) }, - { (15, 0), 0, (SubIndex.Radicand, 0) }, - { (15, 8), 0, (SubIndex.Radicand, 0) }, - { (15, 40), 0, (SubIndex.Degree, 1) }, - { (17, -20), 0, (SubIndex.Radicand, 1) }, - { (17, 0), 0, (SubIndex.Radicand, 1) }, - { (17, 8), 0, (SubIndex.Radicand, 1) }, - { (17, 40), 0, (SubIndex.Radicand, 1) }, - { (19, -20), 0, (SubIndex.Radicand, 1) }, - { (19, 0), 0, (SubIndex.Radicand, 1) }, - { (19, 8), 0, (SubIndex.Radicand, 1) }, - { (19, 40), 0, (SubIndex.Radicand, 1) }, - { (21, -20), 1 }, - { (21, 0), 0, (SubIndex.Radicand, 1) }, - { (21, 8), 0, (SubIndex.Radicand, 1) }, - { (21, 40), 0, (SubIndex.Radicand, 1) }, - { (23, -20), 1 }, - { (23, 0), 0, (SubIndex.Radicand, 1) }, - { (23, 8), 0, (SubIndex.Radicand, 1) }, - { (23, 40), 0, (SubIndex.Radicand, 1) }, - { (26, -20), 1 }, - { (26, 0), 1 }, - { (26, 8), 1 }, - { (26, 40), 1 }, - { (35, -20), 1 }, - { (35, 0), 1 }, - { (35, 8), 1 }, - { (35, 40), 1 }, + { (0, 0), 0 }, + { (5.56, 8.736), 0, (SubIndex.Degree, 0) }, + { (12.56, 8.736), 0, (SubIndex.Degree, 1) }, + { (11.44, 0), 0, (SubIndex.Radicand, 0) }, + { (21.44, 0), 0, (SubIndex.Radicand, 1) }, }; [Theory, MemberData(nameof(RadicalDegreeData))] public void RadicalDegree(PointF point, MathListIndex expected) => Test(@"\sqrt[3]2", point, expected); public static TestData ExponentData => new TestData { - { (-10, -20), 0 }, - { (-10, 0), 0 }, - { (-10, 8), 0 }, - { (-10, 40), 0 }, - { (0, -20), 0 }, { (0, 0), 0 }, - { (0, 8), 0 }, - { (0, 40), 0 }, - { (9, -20), 0, (SubIndex.BetweenBaseAndScripts, 1) }, - { (9, 0), 0, (SubIndex.BetweenBaseAndScripts, 1) }, - { (9, 8), 0, (SubIndex.BetweenBaseAndScripts, 1) }, - // The superscript is closer than the nucleus (and the touch boundaries overlap) - { (9, 40), 0, (SubIndex.Superscript, 0) }, - { (10, -20), 0, (SubIndex.BetweenBaseAndScripts, 1) }, { (10, 0), 0, (SubIndex.BetweenBaseAndScripts, 1) }, - // The nucleus is closer and the touch boundaries overlap - { (10, 8), 0, (SubIndex.BetweenBaseAndScripts, 1) }, - { (10, 40), 0, (SubIndex.Superscript, 0) }, - { (11, -20), 0, (SubIndex.BetweenBaseAndScripts, 1) }, - { (11, 0), 0, (SubIndex.BetweenBaseAndScripts, 1) }, - { (11, 8), 0, (SubIndex.Superscript, 0) }, - { (11, 40), 0, (SubIndex.Superscript, 0) }, - { (17, -20), 1 }, + { (10, 7.26), 0, (SubIndex.Superscript, 0) }, { (17, 0), 1 }, - { (17, 8), 0, (SubIndex.Superscript, 1) }, - { (17, 40), 0, (SubIndex.Superscript, 1) }, - { (30, -20), 1 }, - { (30, 0), 1 }, - { (30, 8), 1 }, - { (30, 40), 1 }, }; [Theory, MemberData(nameof(ExponentData))] public void Exponent(PointF point, MathListIndex expected) => Test("2^3", point, expected); - public static TestData Exponent2Data => - new TestData { - { (55, 0), 1 }, - { (55, 20), 1 }, - { (55, 40), 1 }, - }; - [Theory, MemberData(nameof(Exponent2Data))] // https://github.com/verybadcat/CSharpMath/issues/49 - public void Exponent2(PointF point, MathListIndex expected) => Test("2^{x+y-4}", point, expected); - public static TestData Issue46Data => new TestData { - { (50, 10), 4 }, - { (90, 0), 5 }, - { (90, 20), 5 }, - { (90, 40), 5 }, + { (57.777, 0), 4 }, + { (75.097, 0), 5 }, }; [Theory, MemberData(nameof(Issue46Data))] // https://github.com/verybadcat/CSharpMath/issues/46 public void Issue46(PointF point, MathListIndex expected) => Test("2+x+x^y", point, expected); public static TestData ComplexData => new TestData { - { (-10, -20), 0 }, - { (-10, 0), 0 }, - { (-10, 8), 0 }, - { (-10, 40), 0 }, + { (0, 0), 0 }, // \frac a\frac bc { (0, -20), 0, (SubIndex.Denominator, 0), (SubIndex.Denominator, 0) }, { (0, 0), 0, (SubIndex.Denominator, 0), (SubIndex.Numerator, 0) }, { (0, 8), 0, (SubIndex.Numerator, 0) }, - { (0, 40), 0, (SubIndex.Numerator, 0) }, { (6, -20), 0, (SubIndex.Denominator, 0), (SubIndex.Denominator, 1) }, { (6, 0), 0, (SubIndex.Denominator, 0), (SubIndex.Numerator, 1) }, { (6, 8), 0, (SubIndex.Numerator, 1) }, - { (6, 40), 0, (SubIndex.Numerator, 1) }, { (8, -20), 0, (SubIndex.Denominator, 1) }, - { (8, 0), 0, (SubIndex.Denominator, 0), (SubIndex.Numerator, 1) }, - { (8, 8), 0, (SubIndex.Numerator, 1) }, - { (8, 40), 0, (SubIndex.Numerator, 1) }, - { (10, -20), 0, (SubIndex.Denominator, 1) }, - { (10, 0), 0, (SubIndex.Denominator, 0), (SubIndex.Numerator, 1) }, - { (10, 8), 0, (SubIndex.Numerator, 1) }, - { (10, 40), 0, (SubIndex.Numerator, 1) }, - { (11, -20), 0, (SubIndex.Denominator, 1) }, - { (11, 0), 0, (SubIndex.Denominator, 1) }, - { (11, 8), 0, (SubIndex.Numerator, 1) }, - { (11, 40), 0, (SubIndex.Numerator, 1) }, // \frac\frac123 { (17, -20), 1, (SubIndex.Denominator, 0) }, - { (17, 0), 1, (SubIndex.Denominator, 0) }, { (17, 8), 1, (SubIndex.Numerator, 0), (SubIndex.Denominator, 0) }, { (17, 40), 1, (SubIndex.Numerator, 0), (SubIndex.Numerator, 0) }, { (23, -20), 1, (SubIndex.Denominator, 1) }, - { (23, 0), 1, (SubIndex.Denominator, 1) }, { (23, 8), 1, (SubIndex.Numerator, 1) }, { (23, 40), 1, (SubIndex.Numerator, 0), (SubIndex.Numerator, 1) }, // \sqrt d^e { (27, -20), 2, (SubIndex.Radicand, 0) }, - { (27, 0), 2, (SubIndex.Radicand, 0) }, - { (27, 8), 2, (SubIndex.Radicand, 0) }, - { (27, 40), 2, (SubIndex.Radicand, 0) }, - { (40, -20), 2, (SubIndex.Radicand, 0) }, - { (40, 0), 2, (SubIndex.Radicand, 0) }, - { (40, 8), 2, (SubIndex.Radicand, 0) }, - { (40, 40), 2, (SubIndex.Radicand, 0) }, { (45, -20), 2, (SubIndex.Radicand, 1) }, - { (45, 0), 2, (SubIndex.Radicand, 1) }, - { (45, 8), 2, (SubIndex.Radicand, 1) }, { (45, 40), 2, (SubIndex.Superscript, 0) }, - { (50, -20), 2, (SubIndex.Superscript, 0) }, - { (50, 0), 2, (SubIndex.Superscript, 0) }, - { (50, 8), 2, (SubIndex.Superscript, 0) }, - { (50, 40), 2, (SubIndex.Superscript, 0) }, { (55, -20), 2, (SubIndex.Superscript, 1) }, - { (55, 0), 2, (SubIndex.Superscript, 1) }, - { (55, 8), 2, (SubIndex.Superscript, 1) }, - { (55, 40), 2, (SubIndex.Superscript, 1) }, // \sqrt[5]6 { (60, -20), 3, (SubIndex.Radicand, 0) }, - { (60, 0), 3, (SubIndex.Radicand, 0) }, { (60, 8), 3, (SubIndex.Degree, 0) }, - { (60, 40), 3, (SubIndex.Degree, 0) }, - { (67, -20), 3, (SubIndex.Radicand, 0) }, - { (67, 0), 3, (SubIndex.Radicand, 0) }, - { (67, 8), 3, (SubIndex.Degree, 0) }, - { (67, 40), 3, (SubIndex.Degree, 0) }, - { (73, -20), 3, (SubIndex.Radicand, 0) }, - { (73, 0), 3, (SubIndex.Radicand, 0) }, - { (73, 8), 3, (SubIndex.Radicand, 0) }, { (73, 40), 3, (SubIndex.Degree, 1) }, { (80, -20), 3, (SubIndex.Radicand, 1) }, - { (80, 0), 3, (SubIndex.Radicand, 1) }, - { (80, 8), 3, (SubIndex.Radicand, 1) }, - { (80, 40), 3, (SubIndex.Radicand, 1) }, // \sqrt[f]g^{7_8}_{9^0} - { (87, -20), 4, (SubIndex.Radicand, 0) }, { (87, 0), 4, (SubIndex.Radicand, 0) }, { (87, 8), 4, (SubIndex.Degree, 0) }, - { (87, 40), 4, (SubIndex.Degree, 0) }, - { (90, -20), 4, (SubIndex.Radicand, 0) }, - { (90, 0), 4, (SubIndex.Radicand, 0) }, - { (90, 8), 4, (SubIndex.Degree, 0) }, - { (90, 40), 4, (SubIndex.Degree, 0) }, - { (95, -20), 4, (SubIndex.Radicand, 0) }, - { (95, 0), 4, (SubIndex.Radicand, 0) }, { (95, 8), 4, (SubIndex.Degree, 1) }, - { (95, 40), 4, (SubIndex.Degree, 1) }, - { (100, -20), 4, (SubIndex.Radicand, 0) }, - { (100, 0), 4, (SubIndex.Radicand, 0) }, - { (100, 8), 4, (SubIndex.Radicand, 0) }, - { (100, 40), 4, (SubIndex.Degree, 1) }, { (105, -20), 4, (SubIndex.Subscript, 0) }, { (105, 0), 4, (SubIndex.Radicand, 1) }, - { (105, 8), 4, (SubIndex.Radicand, 1) }, - { (105, 40), 4, (SubIndex.Superscript, 0) }, - { (110, -20), 4, (SubIndex.Subscript, 0) }, - { (110, 0), 4, (SubIndex.Subscript, 0) }, - { (110, 8), 4, (SubIndex.Subscript, 0) }, { (118, 20), 4, (SubIndex.Superscript, 0), (SubIndex.Subscript, 1) }, - { (118, 32), 4, (SubIndex.Superscript, 0), (SubIndex.Subscript, 1) }, - { (110, 40), 4, (SubIndex.Superscript, 0) }, { (115, -20), 4, (SubIndex.Subscript, 0), (SubIndex.BetweenBaseAndScripts, 1) }, { (115, 0), 4, (SubIndex.Subscript, 0), (SubIndex.Superscript, 0) }, - { (115, 8), 4, (SubIndex.Subscript, 0), (SubIndex.Superscript, 0) }, - { (118, 20), 4, (SubIndex.Superscript, 0), (SubIndex.Subscript, 1) }, - { (118, 32), 4, (SubIndex.Superscript, 0), (SubIndex.Subscript, 1) }, - { (115, 40), 4, (SubIndex.Superscript, 0), (SubIndex.BetweenBaseAndScripts, 1) }, { (118, -20), 4, (SubIndex.Subscript, 1) }, - { (118, 0), 4, (SubIndex.Subscript, 0), (SubIndex.Superscript, 1) }, - { (118, 8), 4, (SubIndex.Subscript, 0), (SubIndex.Superscript, 1) }, - { (118, 20), 4, (SubIndex.Superscript, 0), (SubIndex.Subscript, 1) }, - { (118, 32), 4, (SubIndex.Superscript, 0), (SubIndex.Subscript, 1) }, - { (118, 40), 4, (SubIndex.Superscript, 0), (SubIndex.Subscript, 1) }, - { (120, -20), 4, (SubIndex.Subscript, 1) }, { (120, 0), 4, (SubIndex.Subscript, 0), (SubIndex.Superscript, 1) }, - { (120, 8), 4, (SubIndex.Subscript, 0), (SubIndex.Superscript, 1) }, - { (120, 20), 4, (SubIndex.Superscript, 0), (SubIndex.Subscript, 1) }, - { (120, 32), 4, (SubIndex.Superscript, 0), (SubIndex.Subscript, 1) }, - { (120, 40), 4, (SubIndex.Superscript, 0), (SubIndex.Subscript, 1) }, - { (122, -20), 5 }, - { (122, 0), 5 }, - { (122, 8), 5 }, - { (122, 20), 5 }, - { (122, 32), 5 }, - { (122, 40), 5 }, - { (150, -20), 5 }, - { (150, 0), 5 }, - { (150, 8), 5 }, - { (150, 20), 5 }, - { (150, 32), 5 }, - { (150, 40), 5 }, + { (122, -20), 5 } }; - [Theory, MemberData(nameof(ComplexData))] + [Theory(Skip = "Needs updating test data"), MemberData(nameof(ComplexData))] public void Complex(PointF point, MathListIndex expected) => Test(@"\frac a\frac bc\frac\frac123\sqrt d^e\sqrt[5]6\sqrt[f]g^{7_8}_{9^0}", point, expected); public static TestData SineData => new TestData { - { (-10, 10), 0 }, - { (1, 10), 0 }, - { (9, 10), 0 }, - { (16, 10), 1 }, - { (20, 10), 1 }, - { (28, 10), 1 }, - { (35, 10), 1 }, - { (42, 10), 2 }, - { (69, 10), 2 }, + { (0, 0), 0 }, + { (33.333, 0), 1 }, + { (43.333, 0), 2 }, }; [Theory, MemberData(nameof(SineData))] public void Sine(PointF point, MathListIndex expected) => Test(@"\sin\pi", point, expected); From 86769a068e3114947d7cb465a38499f3a9ea2973 Mon Sep 17 00:00:00 2001 From: FoggyFinder Date: Fri, 25 Oct 2019 14:57:11 +0300 Subject: [PATCH 5/5] fix --- .../Extensions/DisplayEditingExtensions.Fraction.cs | 4 ++-- .../Extensions/DisplayEditingExtensions.Radical.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CSharpMath.Editor/Extensions/DisplayEditingExtensions.Fraction.cs b/CSharpMath.Editor/Extensions/DisplayEditingExtensions.Fraction.cs index 8e794c02f..176770334 100644 --- a/CSharpMath.Editor/Extensions/DisplayEditingExtensions.Fraction.cs +++ b/CSharpMath.Editor/Extensions/DisplayEditingExtensions.Fraction.cs @@ -33,9 +33,9 @@ public static MathListIndex IndexForPoint(this FractionDisplay(this FractionDisplay self, MathListIndex index, Color color) where TFont : IFont { diff --git a/CSharpMath.Editor/Extensions/DisplayEditingExtensions.Radical.cs b/CSharpMath.Editor/Extensions/DisplayEditingExtensions.Radical.cs index 0a97760b8..445034397 100644 --- a/CSharpMath.Editor/Extensions/DisplayEditingExtensions.Radical.cs +++ b/CSharpMath.Editor/Extensions/DisplayEditingExtensions.Radical.cs @@ -37,9 +37,9 @@ public static MathListIndex IndexForPoint(this RadicalDisplay(this RadicalDisplay self, MathListIndex index, Color color) where TFont : IFont {