Index: Core/Common/src/Core.Common.Base/Core.Common.Base.csproj =================================================================== diff -u -r2fd427d95bfd8c000da089fedcf7b2fe2ca592e2 -r365f33fe0130eac94cacb979165488d9ae124f3c --- Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision 2fd427d95bfd8c000da089fedcf7b2fe2ca592e2) +++ Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -102,7 +102,7 @@ - + Fisheye: Tag 365f33fe0130eac94cacb979165488d9ae124f3c refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Base/Geometry/Segment2DCollectionExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/src/Core.Common.Base/Geometry/Segment2DExtensions.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Base/Geometry/Segment2DExtensions.cs (revision 0) +++ Core/Common/src/Core.Common.Base/Geometry/Segment2DExtensions.cs (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -0,0 +1,80 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Core.Common.Base.Geometry +{ + /// + /// Extension methods for objects. + /// + public static class Segment2DExtensions + { + /// + /// Interpolates the segments on . + /// + /// The segments to interpolate on. + /// The x value to use for interpolation. + /// The interpolated y value of the segment that is closest to + /// or when no interpolation was found. + /// Thrown when is null. + public static double Interpolate(this IEnumerable segments, double x) + { + if (segments == null) + { + throw new ArgumentNullException(nameof(segments)); + } + + Segment2D segment = segments.LastOrDefault(s => s.FirstPoint.X <= x) ?? segments.First(); + + return segment.Interpolate(x); + } + + /// + /// Interpolate the segment on + /// + /// The segment to interpolate on. + /// The x value to use for interpolation. + /// The interpolated y value on the segment or + /// when no interpolation was found. + /// Thrown when is null. + public static double Interpolate(this Segment2D segment, double x) + { + if (segment == null) + { + throw new ArgumentNullException(nameof(segment)); + } + + double differenceInX = segment.SecondPoint.X - segment.FirstPoint.X; + if (Math.Abs(differenceInX) < 1e-6) + { + return double.NaN; + } + + double m = (segment.SecondPoint.Y - segment.FirstPoint.Y) / differenceInX; + double b = segment.FirstPoint.Y - (m * segment.FirstPoint.X); + + return m * x + b; + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Base.Test/Core.Common.Base.Test.csproj =================================================================== diff -u -r2fd427d95bfd8c000da089fedcf7b2fe2ca592e2 -r365f33fe0130eac94cacb979165488d9ae124f3c --- Core/Common/test/Core.Common.Base.Test/Core.Common.Base.Test.csproj (.../Core.Common.Base.Test.csproj) (revision 2fd427d95bfd8c000da089fedcf7b2fe2ca592e2) +++ Core/Common/test/Core.Common.Base.Test/Core.Common.Base.Test.csproj (.../Core.Common.Base.Test.csproj) (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -93,7 +93,7 @@ - + Fisheye: Tag 365f33fe0130eac94cacb979165488d9ae124f3c refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Base.Test/Geometry/Segment2DCollectionExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/test/Core.Common.Base.Test/Geometry/Segment2DExtensionsTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Base.Test/Geometry/Segment2DExtensionsTest.cs (revision 0) +++ Core/Common/test/Core.Common.Base.Test/Geometry/Segment2DExtensionsTest.cs (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -0,0 +1,253 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Core.Common.Base.Geometry; +using NUnit.Framework; + +namespace Core.Common.Base.Test.Geometry +{ + [TestFixture] + public class Segment2DExtensionsTest + { + [Test] + public void InterpolateOnCollection_SegmentsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => ((IEnumerable) null).Interpolate(0); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("segments", exception.ParamName); + } + + [Test] + [TestCaseSource(nameof(ValidInterpolationCollection))] + public void InterpolateOnCollection_ValidArguments_ReturnsExpectedResult(IEnumerable segments, + double interpolateOnX, + double expectedY) + { + // Call + double actualY = segments.Interpolate(interpolateOnX); + + // Assert + Assert.AreEqual(expectedY, actualY); + } + + [Test] + [TestCaseSource(nameof(InvalidInterpolationCollection))] + public void InterpolateOnCollection_InvalidArguments_ReturnsNaN(IEnumerable segments, + double interpolateOnX) + { + // Call + double actualY = segments.Interpolate(interpolateOnX); + + // Assert + Assert.IsNaN(actualY); + } + + [Test] + public void Interpolate_SegmentsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => ((Segment2D) null).Interpolate(0); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("segment", exception.ParamName); + } + + [Test] + [TestCaseSource(nameof(ValidInterpolationSegment))] + public void Interpolate_ValidArguments_ReturnsExpectedResult(Segment2D segment, + double interpolateOnX, + double expectedY) + { + // Call + double actualY = segment.Interpolate(interpolateOnX); + + // Assert + Assert.AreEqual(expectedY, actualY); + } + + [Test] + [TestCaseSource(nameof(InvalidInterpolationSegment))] + public void Interpolate_InvalidArguments_ReturnsNaN(Segment2D segment, + double interpolateOnX) + { + // Call + double actualY = segment.Interpolate(interpolateOnX); + + // Assert + Assert.IsNaN(actualY); + } + + private static IEnumerable ValidInterpolationSegment() + { + yield return new TestCaseData(new Segment2D(new Point2D(0, 10), new Point2D(10, 100)), 0, 10).SetName("Same as first point that passed through origin"); + + yield return new TestCaseData( + new Segment2D(new Point2D(0, 10), + new Point2D(10, 100)), + -10, + -80).SetName("Left of first point"); + + yield return new TestCaseData( + new Segment2D(new Point2D(1, 10), + new Point2D(10, 100)), + 1, + 10).SetName("Same as first point"); + + yield return new TestCaseData( + new Segment2D(new Point2D(1, 10), + new Point2D(10, 100)), + 10, + 100).SetName("Same as second point"); + + yield return new TestCaseData( + new Segment2D(new Point2D(1, 1), + new Point2D(10, 10)), + 5, + 5).SetName("Slope = 1, b = 0"); + + yield return new TestCaseData( + new Segment2D(new Point2D(0, 0), + new Point2D(10, 1000)), + 5, + 500).SetName("Slope = 100, b = 0"); + + yield return new TestCaseData( + new Segment2D(new Point2D(0, 0), + new Point2D(-5, -9)), + 5, + (9.0 / 5.0) * 5).SetName("Slope = 9/5, b = 0"); + + yield return new TestCaseData( + new Segment2D(new Point2D(5, 2), + new Point2D(90, 3)), + 50, + ((1 / 85.0) * 50) + (33 / 17.0)).SetName("Slope = 1/85, b = 33/17"); + } + + private static IEnumerable InvalidInterpolationSegment() + { + yield return new TestCaseData( + new Segment2D(new Point2D(0, 10), + new Point2D(0, 10)), + 0).SetName("Vertical line"); + + yield return new TestCaseData( + new Segment2D(new Point2D(0, 0), + new Point2D(double.PositiveInfinity, double.PositiveInfinity)), + 20).SetName("PositiveInfinity"); + + yield return new TestCaseData( + new Segment2D(new Point2D(0, 0), + new Point2D(double.NegativeInfinity, double.NegativeInfinity)), + 20).SetName("NegativeInfinity"); + + yield return new TestCaseData( + new Segment2D(new Point2D(0, 0), + new Point2D(double.NaN, double.NaN)), + 20).SetName("NaN"); + } + + private static IEnumerable ValidInterpolationCollection() + { + yield return new TestCaseData(new[] + { + new Segment2D(new Point2D(-1000, 0), new Point2D(1, 1)), + new Segment2D(new Point2D(1, 1), new Point2D(10, 10)), + new Segment2D(new Point2D(100, 100), new Point2D(1000, 10)) + }, 20, 20).SetName("Slope = 1, b = 0 with other segments"); + + yield return new TestCaseData(new[] + { + new Segment2D(new Point2D(0, 10), new Point2D(10, 100)) + }, 0, 10).SetName("Same as first point that passed through origin"); + + yield return new TestCaseData(new[] + { + new Segment2D(new Point2D(0, 10), new Point2D(10, 100)) + }, -10, -80).SetName("Left of first point"); + + yield return new TestCaseData(new[] + { + new Segment2D(new Point2D(1, 10), new Point2D(10, 100)) + }, 1, 10).SetName("Same as first point"); + + yield return new TestCaseData(new[] + { + new Segment2D(new Point2D(1, 10), new Point2D(10, 100)) + }, 10, 100).SetName("Same as second point"); + + yield return new TestCaseData(new[] + { + new Segment2D(new Point2D(0, 10), new Point2D(10, 10)), + new Segment2D(new Point2D(10, 10), new Point2D(20, 100)) + }, 30, 190).SetName("Right of last point"); + + yield return new TestCaseData(new[] + { + new Segment2D(new Point2D(1, 1), new Point2D(10, 10)) + }, 5, 5).SetName("Slope = 1, b = 0"); + + yield return new TestCaseData(new[] + { + new Segment2D(new Point2D(0, 0), new Point2D(10, 1000)) + }, 5, 500).SetName("Slope = 100, b = 0"); + + yield return new TestCaseData(new[] + { + new Segment2D(new Point2D(0, 0), new Point2D(-5, -9)) + }, 5, (9.0 / 5.0) * 5).SetName("Slope = 9/5, b = 0"); + + yield return new TestCaseData(new[] + { + new Segment2D(new Point2D(5, 2), new Point2D(90, 3)) + }, 50, ((1 / 85.0) * 50) + (33 / 17.0)).SetName("Slope = 1/85, b = 33/17"); + } + + private static IEnumerable InvalidInterpolationCollection() + { + yield return new TestCaseData(new[] + { + new Segment2D(new Point2D(0, 10), new Point2D(0, 10)) + }, 0).SetName("Vertical line"); + + yield return new TestCaseData(new[] + { + new Segment2D(new Point2D(0, 0), new Point2D(double.PositiveInfinity, double.PositiveInfinity)) + }, 20).SetName("PositiveInfinity"); + + yield return new TestCaseData(new[] + { + new Segment2D(new Point2D(0, 0), new Point2D(double.NegativeInfinity, double.NegativeInfinity)) + }, 20).SetName("NegativeInfinity"); + + yield return new TestCaseData(new[] + { + new Segment2D(new Point2D(0, 0), new Point2D(double.NaN, double.NaN)) + }, 20).SetName("NaN"); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsSlice.cs =================================================================== diff -u -r68647f42dd790c7900bdbe376e97322435b4a957 -r365f33fe0130eac94cacb979165488d9ae124f3c --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsSlice.cs (.../MacroStabilityInwardsSlice.cs) (revision 68647f42dd790c7900bdbe376e97322435b4a957) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsSlice.cs (.../MacroStabilityInwardsSlice.cs) (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -175,7 +175,7 @@ public double ExternalLoad { get; } /// - /// Gets the hydraostatic pore pressure. + /// Gets the hydrostatic pore pressure. /// [kN/m²] /// public double HydrostaticPorePressure { get; } Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r5d98c3072517f99bfc6f05a363ea5cf4d6025bd8 -r365f33fe0130eac94cacb979165488d9ae124f3c --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 5d98c3072517f99bfc6f05a363ea5cf4d6025bd8) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -750,6 +750,233 @@ } /// + /// Looks up a localized string similar to Booglengte [m]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_ArcLength { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_ArcLength", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bodemhoek [°]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_BottomAngle { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_BottomAngle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cohesie [kN/m²]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_Cohesion { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_Cohesion", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Waterspanning door consolidatiegraad belasting [kN/m²]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_DegreeOfConsolidationPorePressureLoad { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_DegreeOfConsolidationPorePressureLo" + + "ad", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Waterspanning door consolidatiegraad grond [kN/m²]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_DegreeOfConsolidationPorePressureSoil { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_DegreeOfConsolidationPorePressureSo" + + "il", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Effectieve spanning [kN/m²]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_EffectiveStress { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_EffectiveStress", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Externe belasting [kN/m²]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_ExternalLoad { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_ExternalLoad", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Wrijvingshoek [°]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_FrictionAngle { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_FrictionAngle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Horizontale waterspanning op maaiveld [kN/m²]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_HorizontalPorePressure { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_HorizontalPorePressure", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Spanning belasting [kN/m²]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_LoadStress { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_LoadStress", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Naam. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_Name { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Normaalspanning [kN/m²]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_NormalStress { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_NormalStress", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to OCR [-]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_OverConsolidationRatio { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_OverConsolidationRatio", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Piezometrische waterspanning [kN/m²]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_PiezometricPorePressure { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_PiezometricPorePressure", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to POP [kN/m²]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_Pop { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_Pop", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Waterspanning op maaiveld [kN/m²]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_PorePressure { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_PorePressure", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Schuifspanning [kN/m²]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_ShearStress { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_ShearStress", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Tophoek [°]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_TopAngle { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_TopAngle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Totale waterspanning [kN/m²]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_TotalPorePressure { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_TotalPorePressure", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Verticale waterspanning op maaiveld [kN/m²]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_VerticalPorePressure { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_VerticalPorePressure", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Gewicht [kN/m]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_Weight { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_Weight", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Breedte [m]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_Width { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_Width", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to X centrum [m]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_XCenter { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_XCenter", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Z centrum bodem [m+NAP]. + /// + public static string MacroStabilityInwardsSlicesTable_ColumnHeader_ZCenterBottom { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_ColumnHeader_ZCenterBottom", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lamel {0}. + /// + public static string MacroStabilityInwardsSlicesTable_Name_Slice_0 { + get { + return ResourceManager.GetString("MacroStabilityInwardsSlicesTable_Name_Slice_0", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Onverzadigd gewicht [kN/m³]. /// public static string MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_AbovePhreaticLevel { Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx =================================================================== diff -u -r5d98c3072517f99bfc6f05a363ea5cf4d6025bd8 -r365f33fe0130eac94cacb979165488d9ae124f3c --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx (.../Resources.resx) (revision 5d98c3072517f99bfc6f05a363ea5cf4d6025bd8) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx (.../Resources.resx) (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -658,4 +658,79 @@ Zones extreem + + Booglengte [m] + + + Bodemhoek [°] + + + Cohesie [kN/m²] + + + Waterspanning door consolidatiegraad belasting [kN/m²] + + + Waterspanning door consolidatiegraad grond [kN/m²] + + + Effectieve spanning [kN/m²] + + + Externe belasting [kN/m²] + + + Wrijvingshoek [°] + + + Horizontale waterspanning op maaiveld [kN/m²] + + + Spanning belasting [kN/m²] + + + Normaalspanning [kN/m²] + + + OCR [-] + + + Piezometrische waterspanning [kN/m²] + + + POP [kN/m²] + + + Waterspanning op maaiveld [kN/m²] + + + Schuifspanning [kN/m²] + + + Tophoek [°] + + + Totale waterspanning [kN/m²] + + + Verticale waterspanning op maaiveld [kN/m²] + + + Gewicht [kN/m] + + + Breedte [m] + + + X centrum [m] + + + Z centrum bodem [m+NAP] + + + Naam + + + Lamel {0} + \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj =================================================================== diff -u -r88aeb657842c614e037562cadb293b08862458d4 -r365f33fe0130eac94cacb979165488d9ae124f3c --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj (.../Ringtoets.MacroStabilityInwards.Forms.csproj) (revision 88aeb657842c614e037562cadb293b08862458d4) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj (.../Ringtoets.MacroStabilityInwards.Forms.csproj) (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -96,6 +96,7 @@ + UserControl @@ -140,6 +141,9 @@ MacroStabilityInwardsFailureMechanismView.cs + + UserControl + UserControl Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFormattedSliceRow.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFormattedSliceRow.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFormattedSliceRow.cs (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -0,0 +1,223 @@ +// Copyright (C) Stichting Deltares ²017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Ringtoets.MacroStabilityInwards.Data; +using Ringtoets.MacroStabilityInwards.Forms.Properties; + +namespace Ringtoets.MacroStabilityInwards.Forms.Views +{ + /// + /// This class represents a row of . + /// + public class MacroStabilityInwardsFormattedSliceRow + { + /// + /// Creates a new instance of . + /// + /// The to format. + /// Thrown when + /// is null. + public MacroStabilityInwardsFormattedSliceRow(MacroStabilityInwardsSlice slice, int index) + { + if (slice == null) + { + throw new ArgumentNullException(nameof(slice)); + } + + Name = string.Format(Resources.MacroStabilityInwardsSlicesTable_Name_Slice_0, index); + XCenter = new RoundedDouble(2, (slice.TopLeftPoint.X + slice.TopRightPoint.X) / 2.0); + ZCenterBottom = new RoundedDouble(2, new Segment2D(slice.BottomLeftPoint, slice.BottomRightPoint).Interpolate(XCenter)); + Width = new RoundedDouble(2, slice.TopRightPoint.X - slice.TopLeftPoint.X); + ArcLength = new RoundedDouble(2, slice.BottomLeftPoint.GetEuclideanDistanceTo(slice.BottomRightPoint)); + BottomAngle = new RoundedDouble(2, GetAngleBetween(slice.BottomRightPoint, slice.BottomLeftPoint)); + TopAngle = new RoundedDouble(2, GetAngleBetween(slice.TopRightPoint, slice.TopLeftPoint)); + FrictionAngle = new RoundedDouble(3, slice.FrictionAngle); + Cohesion = new RoundedDouble(3, slice.Cohesion); + EffectiveStress = new RoundedDouble(3, slice.EffectiveStress); + TotalPorePressure = new RoundedDouble(3, slice.TotalPorePressure); + Weight = new RoundedDouble(3, slice.Weight); + PiezometricPorePressure = new RoundedDouble(3, slice.PiezometricPorePressure); + DegreeOfConsolidationPorePressureSoil = new RoundedDouble(3, slice.DegreeOfConsolidationPorePressureSoil); + DegreeOfConsolidationPorePressureLoad = new RoundedDouble(3, slice.DegreeOfConsolidationPorePressureLoad); + PorePressure = new RoundedDouble(3, slice.PorePressure); + VerticalPorePressure = new RoundedDouble(3, slice.VerticalPorePressure); + HorizontalPorePressure = new RoundedDouble(3, slice.HorizontalPorePressure); + ExternalLoad = new RoundedDouble(3, slice.ExternalLoad); + OverConsolidationRatio = new RoundedDouble(3, slice.OverConsolidationRatio); + Pop = new RoundedDouble(3, slice.Pop); + NormalStress = new RoundedDouble(3, slice.NormalStress); + ShearStress = new RoundedDouble(3, slice.ShearStress); + LoadStress = new RoundedDouble(3, slice.LoadStress); + } + + /// + /// Gets the name of the slice. + /// + public string Name { get; } + + /// + /// Gets the load stress of the slice. + /// [kN/m²] + /// + public RoundedDouble LoadStress { get; } + + /// + /// Gets the shear stress of the slice. + /// [kN/m²] + /// + public RoundedDouble ShearStress { get; } + + /// + /// Gets the normal stress of the slice. + /// [kN/m²] + /// + public RoundedDouble NormalStress { get; } + + /// + /// Gets the POP of the slice. + /// [kN/m²] + /// + public RoundedDouble Pop { get; } + + /// + /// Gets the over consolidation ratio of the slice. + /// [-] + /// + public RoundedDouble OverConsolidationRatio { get; } + + /// + /// Gets the external load of the slice. + /// [kN/m²] + /// + public RoundedDouble ExternalLoad { get; } + + /// + /// Gets the horizontal pressure of the slice. + /// [kN/m²] + /// + public RoundedDouble HorizontalPorePressure { get; } + + /// + /// Gets the vertical pore pressure of the slice. + /// [kN/m²] + /// + public RoundedDouble VerticalPorePressure { get; } + + /// + /// Gets the pore pressure of the slice. + /// [kN/m²] + /// + public RoundedDouble PorePressure { get; } + + /// + /// Gets the pore pressure from degree of consolidation load of the slice. + /// [kN/m²] + /// + public RoundedDouble DegreeOfConsolidationPorePressureLoad { get; } + + /// + /// Gets the pore pressure from degree of consolidation soil of the slice. + /// [kN/m²] + /// + public RoundedDouble DegreeOfConsolidationPorePressureSoil { get; } + + /// + /// Gets the piezometric pore pressure of the slice. + /// [kN/m²] + /// + public RoundedDouble PiezometricPorePressure { get; } + + /// + /// Gets the weight of the slice. + /// [kN/m] + /// + public RoundedDouble Weight { get; } + + /// + /// Gets the total pore pressure of the slice. + /// [kN/m²] + /// + public RoundedDouble TotalPorePressure { get; } + + /// + /// Gets the X center point of the slice. + /// [m] + /// + public RoundedDouble XCenter { get; } + + /// + /// Gets the Z center bottom point of the slice. + /// [m+NAP] + /// + public RoundedDouble ZCenterBottom { get; } + + /// + /// Gets the width of the slice. + /// [m] + /// + public RoundedDouble Width { get; } + + /// + /// Gets the arc length of the slice. + /// [m] + /// + public RoundedDouble ArcLength { get; } + + /// + /// Gets the top angle of the slice. + /// [°] + /// + public RoundedDouble TopAngle { get; } + + /// + /// Gets the bottom angle of the slice. + /// [°] + /// + public RoundedDouble BottomAngle { get; } + + /// + /// Gets the friction angle of the slice. + /// [°] + /// + public RoundedDouble FrictionAngle { get; } + + /// + /// Gets the cohesion of the slice. + /// [kN/m²] + /// + public RoundedDouble Cohesion { get; } + + /// + /// Gets the effective stress of the slice. + /// [kN/m²] + /// + public RoundedDouble EffectiveStress { get; } + + private static double GetAngleBetween(Point2D pointA, Point2D pointB) + { + return Math.Atan2(pointA.Y - pointB.Y, + pointA.X - pointB.X) * (180 / Math.PI); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputView.Designer.cs =================================================================== diff -u -r3afbd3fd6c74d447b520eb1182e677db4816ac68 -r365f33fe0130eac94cacb979165488d9ae124f3c --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputView.Designer.cs (.../MacroStabilityInwardsOutputView.Designer.cs) (revision 3afbd3fd6c74d447b520eb1182e677db4816ac68) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputView.Designer.cs (.../MacroStabilityInwardsOutputView.Designer.cs) (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -39,25 +39,31 @@ private void InitializeComponent() { this.splitContainer = new System.Windows.Forms.SplitContainer(); - this.macroStabilityInwardsOutputChartControl = new MacroStabilityInwardsOutputChartControl(); + this.macroStabilityInwardsOutputChartControl = new Ringtoets.MacroStabilityInwards.Forms.Views.MacroStabilityInwardsOutputChartControl(); + this.slicesTable = new Ringtoets.MacroStabilityInwards.Forms.Views.MacroStabilityInwardsSlicesTable(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); this.splitContainer.Panel1.SuspendLayout(); + this.splitContainer.Panel2.SuspendLayout(); this.splitContainer.SuspendLayout(); this.SuspendLayout(); // // splitContainer // + this.splitContainer.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer.Location = new System.Drawing.Point(0, 0); this.splitContainer.Name = "splitContainer"; this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal; - this.splitContainer.BorderStyle = BorderStyle.FixedSingle; // // splitContainer.Panel1 // this.splitContainer.Panel1.Controls.Add(this.macroStabilityInwardsOutputChartControl); + // + // splitContainer.Panel2 + // + this.splitContainer.Panel2.Controls.Add(this.slicesTable); this.splitContainer.Size = new System.Drawing.Size(150, 150); - this.splitContainer.SplitterDistance = 75; + this.splitContainer.SplitterDistance = 100; this.splitContainer.TabIndex = 0; // // macroStabilityInwardsOutputChartControl @@ -66,16 +72,31 @@ this.macroStabilityInwardsOutputChartControl.Dock = System.Windows.Forms.DockStyle.Fill; this.macroStabilityInwardsOutputChartControl.Location = new System.Drawing.Point(0, 0); this.macroStabilityInwardsOutputChartControl.Name = "macroStabilityInwardsOutputChartControl"; - this.macroStabilityInwardsOutputChartControl.Size = new System.Drawing.Size(150, 75); + this.macroStabilityInwardsOutputChartControl.Size = new System.Drawing.Size(148, 98); this.macroStabilityInwardsOutputChartControl.TabIndex = 0; // + // slicesTable + // + this.slicesTable.AutoSize = true; + this.slicesTable.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.slicesTable.Dock = System.Windows.Forms.DockStyle.Fill; + this.slicesTable.Location = new System.Drawing.Point(0, 0); + this.slicesTable.Margin = new System.Windows.Forms.Padding(0); + this.slicesTable.MultiSelect = true; + this.slicesTable.Name = "slicesTable"; + this.slicesTable.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.RowHeaderSelect; + this.slicesTable.Size = new System.Drawing.Size(148, 44); + this.slicesTable.TabIndex = 0; + // // MacroStabilityInwardsOutputView // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.splitContainer); this.Name = "MacroStabilityInwardsOutputView"; this.splitContainer.Panel1.ResumeLayout(false); + this.splitContainer.Panel2.ResumeLayout(false); + this.splitContainer.Panel2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit(); this.splitContainer.ResumeLayout(false); this.ResumeLayout(false); @@ -86,5 +107,6 @@ private System.Windows.Forms.SplitContainer splitContainer; private MacroStabilityInwardsOutputChartControl macroStabilityInwardsOutputChartControl; + private MacroStabilityInwardsSlicesTable slicesTable; } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputView.cs =================================================================== diff -u -r4acb5ca07c10a411648e4ac3fe6f15109dfca3e0 -r365f33fe0130eac94cacb979165488d9ae124f3c --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputView.cs (.../MacroStabilityInwardsOutputView.cs) (revision 4acb5ca07c10a411648e4ac3fe6f15109dfca3e0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputView.cs (.../MacroStabilityInwardsOutputView.cs) (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -43,8 +43,8 @@ { InitializeComponent(); - calculationObserver = new Observer(UpdateChartData); - inputObserver = new Observer(UpdateChartData); + calculationObserver = new Observer(UpdateViewData); + inputObserver = new Observer(UpdateViewData); } public object Data @@ -61,6 +61,7 @@ inputObserver.Observable = data?.InputParameters; macroStabilityInwardsOutputChartControl.Data = data; + UpdateTableData(); } } @@ -84,9 +85,15 @@ base.Dispose(disposing); } - private void UpdateChartData() + private void UpdateViewData() { macroStabilityInwardsOutputChartControl.UpdateChartData(); + UpdateTableData(); } + + private void UpdateTableData() + { + slicesTable.SetData(data?.Output?.SlidingCurve.Slices); + } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsSlicesTable.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsSlicesTable.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsSlicesTable.cs (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -0,0 +1,130 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Collections.Generic; +using System.Linq; +using Core.Common.Controls.DataGrid; +using Ringtoets.MacroStabilityInwards.Data; +using Ringtoets.MacroStabilityInwards.Forms.Properties; + +namespace Ringtoets.MacroStabilityInwards.Forms.Views +{ + /// + /// This class defines a table in which properties of instances + /// are shown as rows. + /// + public class MacroStabilityInwardsSlicesTable : DataGridViewControl + { + /// + /// Creates a new instance of . + /// + public MacroStabilityInwardsSlicesTable() + { + AddColumns(); + } + + /// + /// Sets the given for which the properties + /// are shown in the table. + /// + /// The collection of slices to show. + public void SetData(IEnumerable slices) + { + SetDataSource(slices?.Select((data, index) => new MacroStabilityInwardsFormattedSliceRow(data, index + 1)).ToArray()); + } + + private void AddColumns() + { + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.Name), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_Name, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.XCenter), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_XCenter, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.ZCenterBottom), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_ZCenterBottom, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.Width), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_Width, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.ArcLength), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_ArcLength, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.TopAngle), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_TopAngle, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.BottomAngle), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_BottomAngle, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.FrictionAngle), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_FrictionAngle, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.Cohesion), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_Cohesion, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.EffectiveStress), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_EffectiveStress, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.TotalPorePressure), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_TotalPorePressure, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.Weight), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_Weight, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.PiezometricPorePressure), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_PiezometricPorePressure, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.DegreeOfConsolidationPorePressureSoil), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_DegreeOfConsolidationPorePressureSoil, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.DegreeOfConsolidationPorePressureLoad), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_DegreeOfConsolidationPorePressureLoad, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.PorePressure), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_PorePressure, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.VerticalPorePressure), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_VerticalPorePressure, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.HorizontalPorePressure), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_HorizontalPorePressure, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.ExternalLoad), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_ExternalLoad, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.OverConsolidationRatio), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_OverConsolidationRatio, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.Pop), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_Pop, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.NormalStress), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_NormalStress, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.ShearStress), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_ShearStress, + true); + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSliceRow.LoadStress), + Resources.MacroStabilityInwardsSlicesTable_ColumnHeader_LoadStress, + true); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj =================================================================== diff -u -rda004b349d777118e3fdf7dddca87c7e1fc5b596 -r365f33fe0130eac94cacb979165488d9ae124f3c --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj (.../Ringtoets.MacroStabilityInwards.Forms.Test.csproj) (revision da004b349d777118e3fdf7dddca87c7e1fc5b596) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj (.../Ringtoets.MacroStabilityInwards.Forms.Test.csproj) (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -104,6 +104,7 @@ + @@ -115,6 +116,7 @@ + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFormattedSliceRowTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFormattedSliceRowTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFormattedSliceRowTest.cs (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -0,0 +1,150 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.MacroStabilityInwards.Data; +using Ringtoets.MacroStabilityInwards.Forms.Views; + +namespace Ringtoets.MacroStabilityInwards.Forms.Test.Views +{ + public class MacroStabilityInwardsFormattedSliceRowTest + { + [Test] + public void Constructor_SliceNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new MacroStabilityInwardsFormattedSliceRow(null, 2); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("slice", paramName); + } + + [Test] + public void Constructor_WithSlice_ExpectedValues() + { + // Setup + var slice = new MacroStabilityInwardsSlice( + new Point2D(0, 10), + new Point2D(10, 8), + new Point2D(0, 2), + new Point2D(10, 1), + new MacroStabilityInwardsSlice.ConstructionProperties + { + Cohesion = double.NaN, + FrictionAngle = 2.0, + EffectiveStress = 3.0, + TotalPorePressure = 4.0, + Weight = 5.0, + PiezometricPorePressure = 6.0, + DegreeOfConsolidationPorePressureSoil = 7.0, + DegreeOfConsolidationPorePressureLoad = 8.0, + PorePressure = 9.0, + VerticalPorePressure = 10.0, + HorizontalPorePressure = 11.0, + ExternalLoad = 12.0, + OverConsolidationRatio = 13.0, + Pop = 14.0, + NormalStress = 15.0, + ShearStress = 16.0, + LoadStress = 17.0 + }); + + // Call + var formattedSliceRow = new MacroStabilityInwardsFormattedSliceRow(slice, 3); + + // Assert + Assert.AreEqual("Lamel 3", formattedSliceRow.Name); + + Assert.AreEqual(2, formattedSliceRow.XCenter.NumberOfDecimalPlaces); + Assert.AreEqual(5.0, formattedSliceRow.XCenter, formattedSliceRow.XCenter.GetAccuracy()); + + Assert.AreEqual(2, formattedSliceRow.ZCenterBottom.NumberOfDecimalPlaces); + Assert.AreEqual(1.5, formattedSliceRow.ZCenterBottom, formattedSliceRow.ZCenterBottom.GetAccuracy()); + + Assert.AreEqual(2, formattedSliceRow.Width.NumberOfDecimalPlaces); + Assert.AreEqual(10.0, formattedSliceRow.Width, formattedSliceRow.Width.GetAccuracy()); + + Assert.AreEqual(2, formattedSliceRow.ArcLength.NumberOfDecimalPlaces); + Assert.AreEqual(10.05, formattedSliceRow.ArcLength, formattedSliceRow.ArcLength.GetAccuracy()); + + Assert.AreEqual(2, formattedSliceRow.BottomAngle.NumberOfDecimalPlaces); + Assert.AreEqual(-5.71, formattedSliceRow.BottomAngle, formattedSliceRow.BottomAngle.GetAccuracy()); + + Assert.AreEqual(2, formattedSliceRow.TopAngle.NumberOfDecimalPlaces); + Assert.AreEqual(-11.31, formattedSliceRow.TopAngle, formattedSliceRow.TopAngle.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.FrictionAngle.NumberOfDecimalPlaces); + Assert.AreEqual(2.0, formattedSliceRow.FrictionAngle, formattedSliceRow.FrictionAngle.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.Cohesion.NumberOfDecimalPlaces); + Assert.AreEqual(double.NaN, formattedSliceRow.Cohesion, formattedSliceRow.Cohesion.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.EffectiveStress.NumberOfDecimalPlaces); + Assert.AreEqual(3.0, formattedSliceRow.EffectiveStress, formattedSliceRow.EffectiveStress.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.TotalPorePressure.NumberOfDecimalPlaces); + Assert.AreEqual(4.0, formattedSliceRow.TotalPorePressure, formattedSliceRow.TotalPorePressure.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.Weight.NumberOfDecimalPlaces); + Assert.AreEqual(5.0, formattedSliceRow.Weight, formattedSliceRow.Weight.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.PiezometricPorePressure.NumberOfDecimalPlaces); + Assert.AreEqual(6.0, formattedSliceRow.PiezometricPorePressure, formattedSliceRow.PiezometricPorePressure.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.DegreeOfConsolidationPorePressureSoil.NumberOfDecimalPlaces); + Assert.AreEqual(7.0, formattedSliceRow.DegreeOfConsolidationPorePressureSoil, formattedSliceRow.DegreeOfConsolidationPorePressureSoil.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.DegreeOfConsolidationPorePressureLoad.NumberOfDecimalPlaces); + Assert.AreEqual(8.0, formattedSliceRow.DegreeOfConsolidationPorePressureLoad, formattedSliceRow.DegreeOfConsolidationPorePressureLoad.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.PorePressure.NumberOfDecimalPlaces); + Assert.AreEqual(9.0, formattedSliceRow.PorePressure, formattedSliceRow.PorePressure.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.VerticalPorePressure.NumberOfDecimalPlaces); + Assert.AreEqual(10.0, formattedSliceRow.VerticalPorePressure, formattedSliceRow.VerticalPorePressure.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.HorizontalPorePressure.NumberOfDecimalPlaces); + Assert.AreEqual(11.0, formattedSliceRow.HorizontalPorePressure, formattedSliceRow.HorizontalPorePressure.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.ExternalLoad.NumberOfDecimalPlaces); + Assert.AreEqual(12.0, formattedSliceRow.ExternalLoad, formattedSliceRow.ExternalLoad.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.OverConsolidationRatio.NumberOfDecimalPlaces); + Assert.AreEqual(13.0, formattedSliceRow.OverConsolidationRatio, formattedSliceRow.OverConsolidationRatio.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.Pop.NumberOfDecimalPlaces); + Assert.AreEqual(14.0, formattedSliceRow.Pop, formattedSliceRow.Pop.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.NormalStress.NumberOfDecimalPlaces); + Assert.AreEqual(15.0, formattedSliceRow.NormalStress, formattedSliceRow.NormalStress.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.ShearStress.NumberOfDecimalPlaces); + Assert.AreEqual(16.0, formattedSliceRow.ShearStress, formattedSliceRow.ShearStress.GetAccuracy()); + + Assert.AreEqual(3, formattedSliceRow.LoadStress.NumberOfDecimalPlaces); + Assert.AreEqual(17.0, formattedSliceRow.LoadStress, formattedSliceRow.LoadStress.GetAccuracy()); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFormattedSoilLayerDataRowTest.cs =================================================================== diff -u -rfe9be55b75061a8035a3388a2d1bb8f80d49f0f8 -r365f33fe0130eac94cacb979165488d9ae124f3c --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFormattedSoilLayerDataRowTest.cs (.../MacroStabilityInwardsFormattedSoilLayerDataRowTest.cs) (revision fe9be55b75061a8035a3388a2d1bb8f80d49f0f8) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFormattedSoilLayerDataRowTest.cs (.../MacroStabilityInwardsFormattedSoilLayerDataRowTest.cs) (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -41,7 +41,8 @@ TestDelegate test = () => new MacroStabilityInwardsFormattedSoilLayerDataRow(null); // Assert - Assert.Throws(test); + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("layerData", paramName); } [Test] Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsOutputViewTest.cs =================================================================== diff -u -ree422c0282fbaf9bb64b1661f72910964a8a0737 -r365f33fe0130eac94cacb979165488d9ae124f3c --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsOutputViewTest.cs (.../MacroStabilityInwardsOutputViewTest.cs) (revision ee422c0282fbaf9bb64b1661f72910964a8a0737) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsOutputViewTest.cs (.../MacroStabilityInwardsOutputViewTest.cs) (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -21,10 +21,12 @@ using System.Linq; using System.Windows.Forms; +using Core.Common.Base; using Core.Common.Base.Geometry; using Core.Components.Chart.Data; using Core.Components.Chart.Forms; using NUnit.Framework; +using Rhino.Mocks; using Ringtoets.Common.Forms.TestUtil; using Ringtoets.MacroStabilityInwards.Data; using Ringtoets.MacroStabilityInwards.Data.SoilProfile; @@ -50,13 +52,19 @@ Assert.IsInstanceOf(view); Assert.IsInstanceOf(view); Assert.IsNull(view.Data); + Assert.IsNotNull(view.Chart); Assert.AreEqual(1, view.Controls.Count); var splitContainer = view.Controls[0] as SplitContainer; Assert.IsNotNull(splitContainer); + Assert.AreEqual(1, splitContainer.Panel1.Controls.Count); - Assert.IsEmpty(splitContainer.Panel2.Controls); + Assert.AreEqual(1, splitContainer.Panel2.Controls.Count); Assert.IsInstanceOf(splitContainer.Panel1.Controls[0]); + Assert.IsInstanceOf(splitContainer.Panel2.Controls[0]); + + var tableControl = (MacroStabilityInwardsSlicesTable) splitContainer.Panel2.Controls[0]; + CollectionAssert.IsEmpty(tableControl.Rows); } } @@ -306,11 +314,95 @@ } } + [Test] + public void GivenViewWithOutputSet_WhenOutputUpdated_ThenTableUpdated() + { + // Given + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + using (var view = new MacroStabilityInwardsOutputView()) + { + MacroStabilityInwardsSlicesTable slicesTable = GetSlicesTable(view); + + var outputWithoutSlices = new MacroStabilityInwardsOutput(new MacroStabilityInwardsSlidingCurve(MacroStabilityInwardsSlidingCircleTestFactory.Create(), + MacroStabilityInwardsSlidingCircleTestFactory.Create(), + new[] + { + MacroStabilityInwardsSliceTestFactory.CreateSlice() + }, 0, 0), + new MacroStabilityInwardsSlipPlaneUpliftVan(MacroStabilityInwardsGridTestFactory.Create(), + MacroStabilityInwardsGridTestFactory.Create(), + new double[0]), + new MacroStabilityInwardsOutput.ConstructionProperties()); + + var calculation = new MacroStabilityInwardsCalculationScenario + { + Output = outputWithoutSlices + }; + + view.Data = calculation; + + // Precondition + Assert.AreEqual(1, slicesTable.Rows.Count); + + // When + calculation.InputParameters.Attach(observer); + calculation.Output = MacroStabilityInwardsOutputTestFactory.CreateOutput(); + calculation.InputParameters.NotifyObservers(); + + // Then + Assert.AreEqual(3, slicesTable.Rows.Count); + mocks.VerifyAll(); + } + } + + [Test] + public void GivenViewWithOutputSet_WhenOutputCleared_ThenTableCleared() + { + // Given + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + using (var view = new MacroStabilityInwardsOutputView()) + { + MacroStabilityInwardsSlicesTable slicesTable = GetSlicesTable(view); + + var calculation = new MacroStabilityInwardsCalculationScenario + { + Output = MacroStabilityInwardsOutputTestFactory.CreateOutput() + }; + + view.Data = calculation; + + // Precondition + Assert.AreEqual(3, slicesTable.Rows.Count); + + // When + calculation.InputParameters.Attach(observer); + calculation.ClearOutput(); + calculation.InputParameters.NotifyObservers(); + + // Then + Assert.AreEqual(0, slicesTable.Rows.Count); + mocks.VerifyAll(); + } + } + private static MacroStabilityInwardsOutputChartControl GetChartControl(Form form) { return ControlTestHelper.GetControls(form, "macroStabilityInwardsOutputChartControl").Single(); } + private static MacroStabilityInwardsSlicesTable GetSlicesTable(MacroStabilityInwardsOutputView view) + { + return ControlTestHelper.GetControls(view, "slicesTable").Single(); + } + private static IChartControl GetChartControl(MacroStabilityInwardsOutputChartControl view) { return ControlTestHelper.GetControls(view, "chartControl").Single(); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsSlicesTableTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsSlicesTableTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsSlicesTableTest.cs (revision 365f33fe0130eac94cacb979165488d9ae124f3c) @@ -0,0 +1,346 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Windows.Forms; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.MacroStabilityInwards.Data; +using Ringtoets.MacroStabilityInwards.Data.TestUtil; +using Ringtoets.MacroStabilityInwards.Forms.Views; + +namespace Ringtoets.MacroStabilityInwards.Forms.Test.Views +{ + [TestFixture] + public class MacroStabilityInwardsSlicesTableTest + { + private const int nameColumnIndex = 0; + private const int xCenterColumnIndex = 1; + private const int zCenterBottomColumnIndex = 2; + private const int widthColumnIndex = 3; + private const int arcLengthColumnIndex = 4; + private const int topAngleColumnIndex = 5; + private const int bottomAngleColumnIndex = 6; + private const int frictionAngleColumnIndex = 7; + private const int cohesionColumnIndex = 8; + private const int effectiveStressColumnIndex = 9; + private const int totalPorePressureColumnIndex = 10; + private const int weightColumnIndex = 11; + private const int piezometricPorePressureColumnIndex = 12; + private const int degreePorePressureSoilColumnIndex = 13; + private const int degreePorePressureLoadColumnIndex = 14; + private const int porePressureColumnIndex = 15; + private const int verticalPorePressureColumnIndex = 16; + private const int horizontalPorePressureColumnIndex = 17; + private const int externalLoadColumnIndex = 18; + private const int overConsolidationRatioColumnIndex = 19; + private const int popColumnIndex = 20; + private const int normalStressColumnIndex = 21; + private const int shearStressColumnIndex = 22; + private const int loadStressColumnIndex = 23; + + [Test] + public void Constructor_InitializesWithColumns() + { + // Call + using (var table = new MacroStabilityInwardsSlicesTable()) + { + // Assert + DataGridViewColumn nameColumn = table.GetColumnFromIndex(nameColumnIndex); + Assert.AreEqual("Naam", nameColumn.HeaderText); + DataGridViewColumn xCenterColumn = table.GetColumnFromIndex(xCenterColumnIndex); + Assert.AreEqual("X centrum [m]", xCenterColumn.HeaderText); + DataGridViewColumn zCenterBottomColumn = table.GetColumnFromIndex(zCenterBottomColumnIndex); + Assert.AreEqual("Z centrum bodem [m+NAP]", zCenterBottomColumn.HeaderText); + DataGridViewColumn widthColumn = table.GetColumnFromIndex(widthColumnIndex); + Assert.AreEqual("Breedte [m]", widthColumn.HeaderText); + DataGridViewColumn arcLengthColumn = table.GetColumnFromIndex(arcLengthColumnIndex); + Assert.AreEqual("Booglengte [m]", arcLengthColumn.HeaderText); + DataGridViewColumn topAngleColumn = table.GetColumnFromIndex(topAngleColumnIndex); + Assert.AreEqual("Tophoek [°]", topAngleColumn.HeaderText); + DataGridViewColumn bottomAngleColumn = table.GetColumnFromIndex(bottomAngleColumnIndex); + Assert.AreEqual("Bodemhoek [°]", bottomAngleColumn.HeaderText); + DataGridViewColumn frictionAngleColumn = table.GetColumnFromIndex(frictionAngleColumnIndex); + Assert.AreEqual("Wrijvingshoek [°]", frictionAngleColumn.HeaderText); + DataGridViewColumn cohesionColumn = table.GetColumnFromIndex(cohesionColumnIndex); + Assert.AreEqual("Cohesie [kN/m²]", cohesionColumn.HeaderText); + DataGridViewColumn effectiveStressColumn = table.GetColumnFromIndex(effectiveStressColumnIndex); + Assert.AreEqual("Effectieve spanning [kN/m²]", effectiveStressColumn.HeaderText); + DataGridViewColumn totalPorePressureColumn = table.GetColumnFromIndex(totalPorePressureColumnIndex); + Assert.AreEqual("Totale waterspanning [kN/m²]", totalPorePressureColumn.HeaderText); + DataGridViewColumn weightColumn = table.GetColumnFromIndex(weightColumnIndex); + Assert.AreEqual("Gewicht [kN/m]", weightColumn.HeaderText); + DataGridViewColumn piezometricPorePressureColumn = table.GetColumnFromIndex(piezometricPorePressureColumnIndex); + Assert.AreEqual("Piezometrische waterspanning [kN/m²]", piezometricPorePressureColumn.HeaderText); + DataGridViewColumn degreePorePressureSoilColumn = table.GetColumnFromIndex(degreePorePressureSoilColumnIndex); + Assert.AreEqual("Waterspanning door consolidatiegraad grond [kN/m²]", degreePorePressureSoilColumn.HeaderText); + DataGridViewColumn degreePorePressureLoadColumn = table.GetColumnFromIndex(degreePorePressureLoadColumnIndex); + Assert.AreEqual("Waterspanning door consolidatiegraad belasting [kN/m²]", degreePorePressureLoadColumn.HeaderText); + DataGridViewColumn porePressureColumn = table.GetColumnFromIndex(porePressureColumnIndex); + Assert.AreEqual("Waterspanning op maaiveld [kN/m²]", porePressureColumn.HeaderText); + DataGridViewColumn verticalPorePressureColumn = table.GetColumnFromIndex(verticalPorePressureColumnIndex); + Assert.AreEqual("Verticale waterspanning op maaiveld [kN/m²]", verticalPorePressureColumn.HeaderText); + DataGridViewColumn horizontalPorePressureColumn = table.GetColumnFromIndex(horizontalPorePressureColumnIndex); + Assert.AreEqual("Horizontale waterspanning op maaiveld [kN/m²]", horizontalPorePressureColumn.HeaderText); + DataGridViewColumn externalLoadColumn = table.GetColumnFromIndex(externalLoadColumnIndex); + Assert.AreEqual("Externe belasting [kN/m²]", externalLoadColumn.HeaderText); + DataGridViewColumn overConsolidationRatioColumn = table.GetColumnFromIndex(overConsolidationRatioColumnIndex); + Assert.AreEqual("OCR [-]", overConsolidationRatioColumn.HeaderText); + DataGridViewColumn popColumn = table.GetColumnFromIndex(popColumnIndex); + Assert.AreEqual("POP [kN/m²]", popColumn.HeaderText); + DataGridViewColumn normalStressColumn = table.GetColumnFromIndex(normalStressColumnIndex); + Assert.AreEqual("Normaalspanning [kN/m²]", normalStressColumn.HeaderText); + DataGridViewColumn shearStressColumn = table.GetColumnFromIndex(shearStressColumnIndex); + Assert.AreEqual("Schuifspanning [kN/m²]", shearStressColumn.HeaderText); + DataGridViewColumn loadStressColumn = table.GetColumnFromIndex(loadStressColumnIndex); + Assert.AreEqual("Spanning belasting [kN/m²]", loadStressColumn.HeaderText); + + Assert.Throws(() => table.GetColumnFromIndex(loadStressColumnIndex + 1)); + + CollectionAssert.IsEmpty(table.Rows); + } + } + + [Test] + public void SetData_NoDataAlreadySet_SetNewData() + { + // Setup + using (var table = new MacroStabilityInwardsSlicesTable()) + { + var slices = new[] + { + MacroStabilityInwardsSliceTestFactory.CreateSlice(), + MacroStabilityInwardsSliceTestFactory.CreateSlice(), + MacroStabilityInwardsSliceTestFactory.CreateSlice() + }; + + // Call + table.SetData(slices); + + // Assert + Assert.AreEqual(3, table.Rows.Count); + } + } + + [Test] + public void SetData_SetNullDataAfterDataAlreadySet_ClearsData() + { + // Setup + using (var table = new MacroStabilityInwardsSlicesTable()) + { + var slices = new[] + { + MacroStabilityInwardsSliceTestFactory.CreateSlice(), + MacroStabilityInwardsSliceTestFactory.CreateSlice(), + MacroStabilityInwardsSliceTestFactory.CreateSlice() + }; + table.SetData(slices); + + // Call + table.SetData(null); + + // Assert + Assert.AreEqual(0, table.Rows.Count); + } + } + + [Test] + public void SetData_SetNewDataAfterDataAlreadySet_ClearDataAndAddNewData() + { + // Setup + using (var table = new MacroStabilityInwardsSlicesTable()) + { + var slices = new[] + { + MacroStabilityInwardsSliceTestFactory.CreateSlice(), + MacroStabilityInwardsSliceTestFactory.CreateSlice(), + MacroStabilityInwardsSliceTestFactory.CreateSlice() + }; + table.SetData(new[] + { + MacroStabilityInwardsSliceTestFactory.CreateSlice() + }); + + // Call + table.SetData(slices); + + // Assert + Assert.AreEqual(3, table.Rows.Count); + } + } + + [Test] + public void SetData_WithData_ExpectedValuesInTable() + { + // Setup + using (var table = new MacroStabilityInwardsSlicesTable()) + { + var slices = new[] + { + MacroStabilityInwardsSliceTestFactory.CreateSlice(), + MacroStabilityInwardsSliceTestFactory.CreateSlice(), + MacroStabilityInwardsSliceTestFactory.CreateSlice() + }; + table.SetData(new[] + { + MacroStabilityInwardsSliceTestFactory.CreateSlice() + }); + + // Call + table.SetData(slices); + + // Assert + Assert.AreEqual(3, table.Rows.Count); + for (var i = 0; i < table.Rows.Count; i++) + { + MacroStabilityInwardsSlice slice = slices[i]; + DataGridViewCellCollection rowCells = table.Rows[i].Cells; + + Assert.AreEqual("Lamel " + (i + 1), + rowCells[nameColumnIndex].Value); + + var xCenter = (RoundedDouble) rowCells[xCenterColumnIndex].Value; + Assert.AreEqual((slice.TopLeftPoint.X + slice.TopRightPoint.X) / 2.0, + xCenter, + xCenter.GetAccuracy()); + + var zCenter = (RoundedDouble) rowCells[zCenterBottomColumnIndex].Value; + Assert.AreEqual(new Segment2D(slice.BottomLeftPoint, slice.BottomRightPoint).Interpolate(xCenter), + zCenter, + zCenter.GetAccuracy()); + + var width = (RoundedDouble) rowCells[widthColumnIndex].Value; + Assert.AreEqual(slice.TopRightPoint.X - slice.TopLeftPoint.X, + width, + width.GetAccuracy()); + + var arcLength = (RoundedDouble) rowCells[arcLengthColumnIndex].Value; + Assert.AreEqual(slice.BottomLeftPoint.GetEuclideanDistanceTo(slice.BottomRightPoint), + arcLength, + arcLength.GetAccuracy()); + + var bottomAngle = (RoundedDouble) rowCells[bottomAngleColumnIndex].Value; + Assert.AreEqual(GetAngleBetween(slice.BottomRightPoint, slice.BottomLeftPoint), + bottomAngle, + bottomAngle.GetAccuracy()); + + var topAngle = (RoundedDouble) rowCells[topAngleColumnIndex].Value; + Assert.AreEqual(GetAngleBetween(slice.TopRightPoint, slice.TopLeftPoint), + topAngle, + topAngle.GetAccuracy()); + + var frictionAngle = (RoundedDouble) rowCells[frictionAngleColumnIndex].Value; + Assert.AreEqual(slice.FrictionAngle, + frictionAngle, + frictionAngle.GetAccuracy()); + + var cohesion = (RoundedDouble) rowCells[cohesionColumnIndex].Value; + Assert.AreEqual(slice.Cohesion, + cohesion, + cohesion.GetAccuracy()); + + var effectiveStress = (RoundedDouble) rowCells[effectiveStressColumnIndex].Value; + Assert.AreEqual(slice.EffectiveStress, + effectiveStress, + effectiveStress.GetAccuracy()); + + var totalPorePressure = (RoundedDouble) rowCells[totalPorePressureColumnIndex].Value; + Assert.AreEqual(slice.TotalPorePressure, + totalPorePressure, + totalPorePressure.GetAccuracy()); + + var weight = (RoundedDouble) rowCells[weightColumnIndex].Value; + Assert.AreEqual(slice.Weight, + weight, + weight.GetAccuracy()); + + var piezometricPorePressure = (RoundedDouble) rowCells[piezometricPorePressureColumnIndex].Value; + Assert.AreEqual(slice.PiezometricPorePressure, + piezometricPorePressure, + piezometricPorePressure.GetAccuracy()); + + var degreePorePressureSoil = (RoundedDouble) rowCells[degreePorePressureSoilColumnIndex].Value; + Assert.AreEqual(slice.DegreeOfConsolidationPorePressureSoil, + degreePorePressureSoil, + degreePorePressureSoil.GetAccuracy()); + + var degreePorePressureLoad = (RoundedDouble) rowCells[degreePorePressureLoadColumnIndex].Value; + Assert.AreEqual(slice.DegreeOfConsolidationPorePressureLoad, + degreePorePressureLoad, + degreePorePressureLoad.GetAccuracy()); + + var porePressure = (RoundedDouble) rowCells[porePressureColumnIndex].Value; + Assert.AreEqual(slice.PorePressure, + porePressure, + porePressure.GetAccuracy()); + + var verticalPorePressure = (RoundedDouble) rowCells[verticalPorePressureColumnIndex].Value; + Assert.AreEqual(slice.VerticalPorePressure, + verticalPorePressure, + verticalPorePressure.GetAccuracy()); + + var horizontalPorePressure = (RoundedDouble) rowCells[horizontalPorePressureColumnIndex].Value; + Assert.AreEqual(slice.HorizontalPorePressure, + horizontalPorePressure, + horizontalPorePressure.GetAccuracy()); + + var externalLoad = (RoundedDouble) rowCells[externalLoadColumnIndex].Value; + Assert.AreEqual(slice.ExternalLoad, + externalLoad, + externalLoad.GetAccuracy()); + + var ocr = (RoundedDouble) rowCells[overConsolidationRatioColumnIndex].Value; + Assert.AreEqual(slice.OverConsolidationRatio, + ocr, + ocr.GetAccuracy()); + + var pop = (RoundedDouble) rowCells[popColumnIndex].Value; + Assert.AreEqual(slice.Pop, + pop, + pop.GetAccuracy()); + + var normalStress = (RoundedDouble) rowCells[normalStressColumnIndex].Value; + Assert.AreEqual(slice.NormalStress, + normalStress, + normalStress.GetAccuracy()); + + var shearStress = (RoundedDouble) rowCells[shearStressColumnIndex].Value; + Assert.AreEqual(slice.ShearStress, + shearStress, + shearStress.GetAccuracy()); + + var loadStress = (RoundedDouble) rowCells[loadStressColumnIndex].Value; + Assert.AreEqual(slice.LoadStress, + loadStress, + loadStress.GetAccuracy()); + } + } + } + + private static double GetAngleBetween(Point2D pointA, Point2D pointB) + { + return Math.Atan2(pointA.Y - pointB.Y, + pointA.X - pointB.X) * (180 / Math.PI); + } + } +} \ No newline at end of file