Index: Riskeer/Piping/src/Riskeer.Piping.Forms/PropertyClasses/Probabilistic/ProbabilisticPipingInputContextProperties.cs =================================================================== diff -u -re395a3a2043fd5ab83bcc667a5a7d68e1ae159ef -r6d980fb357f92a82cef3f5d0f8d41fc6efb63d16 --- Riskeer/Piping/src/Riskeer.Piping.Forms/PropertyClasses/Probabilistic/ProbabilisticPipingInputContextProperties.cs (.../ProbabilisticPipingInputContextProperties.cs) (revision e395a3a2043fd5ab83bcc667a5a7d68e1ae159ef) +++ Riskeer/Piping/src/Riskeer.Piping.Forms/PropertyClasses/Probabilistic/ProbabilisticPipingInputContextProperties.cs (.../ProbabilisticPipingInputContextProperties.cs) (revision 6d980fb357f92a82cef3f5d0f8d41fc6efb63d16) @@ -23,11 +23,13 @@ using System.Collections.Generic; using System.ComponentModel; using System.Drawing.Design; +using System.Linq; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Gui.Attributes; using Core.Common.Gui.PropertyBag; using Core.Common.Util.Attributes; +using Riskeer.Common.Data.FailureMechanism; using Riskeer.Common.Forms.ChangeHandlers; using Riskeer.Common.Forms.Helpers; using Riskeer.Common.Forms.PresentationObjects; @@ -70,10 +72,13 @@ private const int diameter70PropertyIndex = 13; private const int saturatedVolumicWeightOfCoverageLayerPropertyIndex = 14; - private const int shouldProfileSpecificIllustrationPointsBeCalculatedPropertyIndex = 15; - private const int shouldSectionSpecificIllustrationPointsBeCalculatedPropertyIndex = 16; - private const int numberOfCategories = 4; + private const int sectionNamePropertyIndex = 15; + private const int sectionLengthPropertyIndex = 16; + private const int shouldProfileSpecificIllustrationPointsBeCalculatedPropertyIndex = 17; + private const int shouldSectionSpecificIllustrationPointsBeCalculatedPropertyIndex = 18; + private const int numberOfCategories = 5; + private readonly IObservablePropertyChangeHandler propertyChangeHandler; /// @@ -153,6 +158,13 @@ return data.AvailablePipingSurfaceLines; } + private FailureMechanismSection GetSection() + { + return data.FailureMechanism + .Sections + .FirstOrDefault(section => data.PipingCalculation.IsSurfaceLineIntersectionWithReferenceLineInSection(Math2D.ConvertPointsToLineSegments(section.Points))); + } + #region Hydraulic data [PropertyOrder(selectedHydraulicBoundaryLocationPropertyIndex)] @@ -392,10 +404,40 @@ #endregion + #region Section information + + [PropertyOrder(sectionNamePropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_FailureMechanismSection), 3, numberOfCategories)] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanismSection_Name_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanismSection_Name_Description))] + public string SectionName + { + get + { + FailureMechanismSection failureMechanismSection = GetSection(); + return failureMechanismSection == null ? "-" : failureMechanismSection.Name; + } + } + + [PropertyOrder(sectionLengthPropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_FailureMechanismSection), 3, numberOfCategories)] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanismSection_Length_Rounded_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanismSection_Length_Rounded_Description))] + public RoundedDouble SectionLength + { + get + { + FailureMechanismSection failureMechanismSection = GetSection(); + return failureMechanismSection == null ? new RoundedDouble(2) : new RoundedDouble(2, failureMechanismSection.Length); + } + } + + #endregion + #region Illustration points [PropertyOrder(shouldProfileSpecificIllustrationPointsBeCalculatedPropertyIndex)] - [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_ProfileSpecificCalculation), 3, numberOfCategories)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_ProfileSpecificCalculation), 4, numberOfCategories)] [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.ShouldIllustrationPointsBeCalculated_DisplayName))] [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.ShouldIllustrationPointsBeCalculated_Description))] public bool ShouldProfileSpecificIllustrationPointsBeCalculated @@ -409,7 +451,7 @@ } [PropertyOrder(shouldSectionSpecificIllustrationPointsBeCalculatedPropertyIndex)] - [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_SectionSpecificCalculation), 4, numberOfCategories)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_SectionSpecificCalculation), 5, numberOfCategories)] [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.ShouldIllustrationPointsBeCalculated_DisplayName))] [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.ShouldIllustrationPointsBeCalculated_Description))] public bool ShouldSectionSpecificIllustrationPointsBeCalculated Index: Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PropertyClasses/Probabilistic/ProbabilisticPipingInputContextPropertiesTest.cs =================================================================== diff -u -re395a3a2043fd5ab83bcc667a5a7d68e1ae159ef -r6d980fb357f92a82cef3f5d0f8d41fc6efb63d16 --- Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PropertyClasses/Probabilistic/ProbabilisticPipingInputContextPropertiesTest.cs (.../ProbabilisticPipingInputContextPropertiesTest.cs) (revision e395a3a2043fd5ab83bcc667a5a7d68e1ae159ef) +++ Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PropertyClasses/Probabilistic/ProbabilisticPipingInputContextPropertiesTest.cs (.../ProbabilisticPipingInputContextPropertiesTest.cs) (revision 6d980fb357f92a82cef3f5d0f8d41fc6efb63d16) @@ -73,9 +73,12 @@ private const int expectedDiameter70PropertyIndex = 13; private const int expectedSaturatedVolumicWeightOfCoverageLayerPropertyIndex = 14; - private const int expectedShouldProfileSpecificCalculateIllustrationPointsPropertyIndex = 15; - private const int expectedShouldSectionSpecificCalculateIllustrationPointsPropertyIndex = 16; + private const int expectedSectionNamePropertyIndex = 15; + private const int expectedSectionLengthPropertyIndex = 16; + private const int expectedShouldProfileSpecificCalculateIllustrationPointsPropertyIndex = 17; + private const int expectedShouldSectionSpecificCalculateIllustrationPointsPropertyIndex = 18; + [Test] public void Constructor_DataNull_ThrowArgumentNullException() { @@ -214,10 +217,11 @@ // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(17, dynamicProperties.Count); + Assert.AreEqual(19, dynamicProperties.Count); - const string hydraulicDataCategory = "\t\t\tHydraulische gegevens"; - const string schematizationCategory = "\t\tSchematisatie"; + const string hydraulicDataCategory = "\t\t\t\tHydraulische gegevens"; + const string schematizationCategory = "\t\t\tSchematisatie"; + const string sectionInformationCategory = "\t\tVakinformatie"; const string profileSpecificCategory = "\tSterkte berekening doorsnede"; const string sectionSpecificCategory = "Sterkte berekening vak"; @@ -330,6 +334,22 @@ true); Assert.IsInstanceOf(saturatedVolumicWeightOfCoverageLayerProperty.Converter); + PropertyDescriptor sectionNameProperty = dynamicProperties[expectedSectionNamePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + sectionNameProperty, + sectionInformationCategory, + "Vaknaam", + "De naam van het vak.", + true); + + PropertyDescriptor sectionLengthProperty = dynamicProperties[expectedSectionLengthPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + sectionLengthProperty, + sectionInformationCategory, + "Lengte* [m]", + "De totale lengte van het vak in meters (afgerond).", + true); + PropertyDescriptor shouldProfileSpecificCalculateIllustrationPointsProperty = dynamicProperties[expectedShouldProfileSpecificCalculateIllustrationPointsPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( shouldProfileSpecificCalculateIllustrationPointsProperty, @@ -386,7 +406,7 @@ // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - const string schematizationCategory = "\t\tSchematisatie"; + const string schematizationCategory = "\t\t\tSchematisatie"; PropertyDescriptor entryPointLProperty = dynamicProperties[expectedEntryPointLPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( @@ -479,13 +499,51 @@ Assert.AreSame(inputParameters.HydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation); + FailureMechanismSection expectedSection = failureMechanism.Sections.First( + s => calculation.IsSurfaceLineIntersectionWithReferenceLineInSection( + Math2D.ConvertPointsToLineSegments(s.Points))); + + Assert.AreEqual(expectedSection.Name, properties.SectionName); + Assert.AreEqual(expectedSection.Length, properties.SectionLength, properties.SectionLength.GetAccuracy()); Assert.AreEqual(inputParameters.ShouldProfileSpecificIllustrationPointsBeCalculated, properties.ShouldProfileSpecificIllustrationPointsBeCalculated); Assert.AreEqual(inputParameters.ShouldSectionSpecificIllustrationPointsBeCalculated, properties.ShouldSectionSpecificIllustrationPointsBeCalculated); mocks.VerifyAll(); } [Test] + public void Constructor_CalculationNotInSection_ReturnExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + var calculation = ProbabilisticPipingCalculationTestFactory.CreateCalculationWithValidInput( + new TestHydraulicBoundaryLocation()); + + ProbabilisticPipingInput inputParameters = calculation.InputParameters; + + var context = new ProbabilisticPipingInputContext(inputParameters, + calculation, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + // Call + var properties = new ProbabilisticPipingInputContextProperties(context, handler); + + // Assert + Assert.AreEqual("-", properties.SectionName); + Assert.AreEqual(0, properties.SectionLength, properties.SectionLength.GetAccuracy()); + + mocks.VerifyAll(); + } + + [Test] public void GivenPropertiesWithData_WhenChangingProperties_ThenPropertiesSetOnInput() { // Given